From 797af75cbd0b7edac91cdc9b1409f92671e21dfa Mon Sep 17 00:00:00 2001 From: Guangxiong Lin Date: Fri, 1 Apr 2022 23:37:40 +0800 Subject: Update key binds of vim --- .vim/after/plugin/keybindings.vim | 55 +++++++++++++++++++++++++++++++++++++ .vim/after/plugin/youcompleteme.vim | 2 ++ .vim/keybindings.vim | 55 ------------------------------------- .vimrc | 3 +- 4 files changed, 58 insertions(+), 57 deletions(-) create mode 100644 .vim/after/plugin/keybindings.vim delete mode 100644 .vim/keybindings.vim 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 +imap +imap +imap +imap :call home() +imap +imap +imap +imap =kill_line() + +cmap +cmap +cmap +cmap +cmap +cmap +cnoremap +cnoremap +cnoremap D: + +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 c :call s:toggle_quickfix() 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 +nnoremap gy :YcmCompleter GoToType nnoremap gr :YcmCompleter GoToReferences nnoremap gi :YcmCompleter GoToImplementation +nnoremap rn :YcmCompleter RefactorRename nmap fs (YCMFindSymbolInDocument) nmap fS (YCMFindSymbolInWorkspace) nmap K (YCMHover) diff --git a/.vim/keybindings.vim b/.vim/keybindings.vim deleted file mode 100644 index b76eb27..0000000 --- a/.vim/keybindings.vim +++ /dev/null @@ -1,55 +0,0 @@ -imap -imap -imap -imap -imap :call home() -imap -imap -imap -imap =kill_line() - -cmap -cmap -cmap -cmap -cmap -cmap -cnoremap -cnoremap -cnoremap D: - -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 c :call s:toggle_quickfix() diff --git a/.vimrc b/.vimrc index 0c92e69..e41b2b1 100644 --- a/.vimrc +++ b/.vimrc @@ -82,8 +82,7 @@ set tags=./.tags;,.tags " mapping let mapleader=',' " change the key nnoremap cd :cd %:p:h :pwd - -source ~/.vim/keybindings.vim +cnoremap highlight Pmenu ctermbg=grey set exrc -- cgit v1.2.3