aboutsummaryrefslogtreecommitdiff
path: root/.vim/keybindings.vim
diff options
context:
space:
mode:
authorgxlin <[email protected]>2021-06-07 19:54:10 +0800
committergxlin <[email protected]>2021-06-07 22:18:37 +0800
commit77af1ea1165d678a0b3953c43eaf7ddfc262ef68 (patch)
treea06c4dc22d5498e8668a859be8a340493f01b184 /.vim/keybindings.vim
parentbd7d13c48383551cb4b81f9a62e3f38431b168c2 (diff)
downloaddotfiles-77af1ea1165d678a0b3953c43eaf7ddfc262ef68.tar.gz
dotfiles-77af1ea1165d678a0b3953c43eaf7ddfc262ef68.tar.bz2
dotfiles-77af1ea1165d678a0b3953c43eaf7ddfc262ef68.zip
Add lsp config for vim
Diffstat (limited to '.vim/keybindings.vim')
-rw-r--r--.vim/keybindings.vim45
1 files changed, 45 insertions, 0 deletions
diff --git a/.vim/keybindings.vim b/.vim/keybindings.vim
new file mode 100644
index 0000000..7a68992
--- /dev/null
+++ b/.vim/keybindings.vim
@@ -0,0 +1,45 @@
+imap <C-b> <Left>
+imap <C-f> <Right>
+imap <C-n> <Down>
+imap <C-p> <Up>
+imap <C-a> <C-o>:call <SID>home()<CR>
+imap <C-e> <End>
+imap <C-d> <Del>
+imap <C-h> <BS>
+imap <C-k> <C-r>=<SID>kill_line()<CR>
+
+cmap <C-p> <Up>
+cmap <C-n> <Down>
+cmap <C-b> <Left>
+cmap <C-f> <Right>
+cmap <C-a> <Home>
+cmap <C-e> <End>
+cnoremap <C-d> <Del>
+cnoremap <C-h> <BS>
+cnoremap <C-k> <C-f>D<C-c><C-c>:<Up>
+
+function! s:home()
+ let start_col = col('.')
+ normal! ^
+ if col('.') == start_col
+ normal! 0
+ endif
+ return ''
+endfunction
+
+function! s:kill_line()
+ let [text_before_cursor, text_after_cursor] = s:split_line_text_at_cursor()
+ if len(text_after_cursor) == 0
+ normal! J
+ else
+ call setline(line('.'), text_before_cursor)
+ endif
+ return ''
+endfunction
+
+function! s:split_line_text_at_cursor()
+ let line_text = getline(line('.'))
+ let text_after_cursor = line_text[col('.')-1 :]
+ let text_before_cursor = (col('.') > 1) ? line_text[: col('.')-2] : ''
+ return [text_before_cursor, text_after_cursor]
+endfunction