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 ++ 2 files changed, 57 insertions(+) create mode 100644 .vim/after/plugin/keybindings.vim (limited to '.vim/after') 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) -- cgit v1.2.3