From f405cca57d09928eda78b04a7b35633a92f91793 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Thu, 4 Jul 2024 19:50:58 +0800 Subject: Update --- vim/init/keymaps.vim | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'vim/init') diff --git a/vim/init/keymaps.vim b/vim/init/keymaps.vim index eca23f9..2475ad8 100644 --- a/vim/init/keymaps.vim +++ b/vim/init/keymaps.vim @@ -14,7 +14,6 @@ " - QUICK_SUBSTITUTE " - 终端支持 " - 编译运行 -" - 符号搜索 " "====================================================================== " vim: set ts=4 sw=4 tw=78 noet : @@ -317,12 +316,16 @@ endfunction command! -nargs=1 -complete=command Redir silent call Redir() nnoremap rr :Redir + + "---------------------------------------------------------------------- " QUICK_SUBSTITUTE " Press n times for area, and for substitute +"---------------------------------------------------------------------- + let g:search_not_in_register = 1 -function! ExpandSelectionForSearch(sep) - if g:search_not_in_register == 1 +function! ExpandSelectionBySearch(sep) + if g:search_not_in_register " Save current selection to register s, and keep selection execute 'norm "sygv' let g:search_not_in_register = 0 @@ -331,18 +334,17 @@ function! ExpandSelectionForSearch(sep) " statusline call feedkeys(a:sep.."\s"..a:sep.."e\") endfunction -function! SubstituteForSearch() - " Apply current for default substitute text +function! SubstituteBySearch() + " Apply current search for default substitute text call feedkeys(":s//\s/g\\") endfunction -vnoremap call ExpandSelectionForSearch('/') -vnoremap call ExpandSelectionForSearch('?') -vnoremap call SubstituteForSearch() +vnoremap call ExpandSelectionBySearch('/') +vnoremap call ExpandSelectionBySearch('?') +vnoremap call SubstituteBySearch() " When leaving visual mode, resume search_not_in_register autocmd Modechanged [vV\x16]*:* let g:search_not_in_register = 1 - "---------------------------------------------------------------------- " Markdown items (temproray solution) "---------------------------------------------------------------------- -- cgit v1.2.3-70-g09d2