aboutsummaryrefslogtreecommitdiff
path: root/.vim/after
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-04-01 23:37:40 +0800
committerGuangxiong Lin <[email protected]>2022-04-01 23:37:40 +0800
commit797af75cbd0b7edac91cdc9b1409f92671e21dfa (patch)
treef121329cad54c0edff832a4eb4a995ce0a75c323 /.vim/after
parent930de6cafd0d683d4b698f54626f7fb4acf157ac (diff)
downloaddotfiles-797af75cbd0b7edac91cdc9b1409f92671e21dfa.tar.gz
dotfiles-797af75cbd0b7edac91cdc9b1409f92671e21dfa.tar.bz2
dotfiles-797af75cbd0b7edac91cdc9b1409f92671e21dfa.zip
Update key binds of vim
Diffstat (limited to '.vim/after')
-rw-r--r--.vim/after/plugin/keybindings.vim55
-rw-r--r--.vim/after/plugin/youcompleteme.vim2
2 files changed, 57 insertions, 0 deletions
diff --git a/.vim/after/plugin/keybindings.vim b/.vim/after/plugin/keybindings.vim
new file mode 100644
index 0000000..b76eb27
--- /dev/null
+++ b/.vim/after/plugin/keybindings.vim
@@ -0,0 +1,55 @@
+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
+
+function! s:toggle_quickfix()
+ if empty(filter(getwininfo(), 'v:val.quickfix'))
+ copen
+ else
+ cclose
+ endif
+endfunction
+
+nnoremap <silent> <leader>c :call s:toggle_quickfix()<cr>
diff --git a/.vim/after/plugin/youcompleteme.vim b/.vim/after/plugin/youcompleteme.vim
index 6f7a266..1e1e6c4 100644
--- a/.vim/after/plugin/youcompleteme.vim
+++ b/.vim/after/plugin/youcompleteme.vim
@@ -31,8 +31,10 @@ let g:ycm_filetype_blacklist = {
\ }
nnoremap gd :YcmCompleter GoTo<CR>
+nnoremap gy :YcmCompleter GoToType<CR>
nnoremap gr :YcmCompleter GoToReferences<CR>
nnoremap gi :YcmCompleter GoToImplementation<CR>
+nnoremap rn :YcmCompleter RefactorRename<space>
nmap <leader>fs <plug>(YCMFindSymbolInDocument)
nmap <leader>fS <plug>(YCMFindSymbolInWorkspace)
nmap K <plug>(YCMHover)