aboutsummaryrefslogtreecommitdiffhomepage
path: root/vim/init
diff options
context:
space:
mode:
Diffstat (limited to 'vim/init')
-rw-r--r--vim/init/keymaps.vim20
1 files changed, 11 insertions, 9 deletions
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 @@
14" - QUICK_SUBSTITUTE 14" - QUICK_SUBSTITUTE
15" - 终端支持 15" - 终端支持
16" - 编译运行 16" - 编译运行
17" - 符号搜索
18" 17"
19"====================================================================== 18"======================================================================
20" vim: set ts=4 sw=4 tw=78 noet : 19" vim: set ts=4 sw=4 tw=78 noet :
@@ -317,12 +316,16 @@ endfunction
317 316
318command! -nargs=1 -complete=command Redir silent call Redir(<q-args>) 317command! -nargs=1 -complete=command Redir silent call Redir(<q-args>)
319nnoremap <leader>rr :Redir<space> 318nnoremap <leader>rr :Redir<space>
319
320
320"---------------------------------------------------------------------- 321"----------------------------------------------------------------------
321" QUICK_SUBSTITUTE 322" QUICK_SUBSTITUTE
322" Press <TAB> n times for area, and <CR> for substitute 323" Press <TAB> n times for area, and <CR> for substitute
324"----------------------------------------------------------------------
325
323let g:search_not_in_register = 1 326let g:search_not_in_register = 1
324function! ExpandSelectionForSearch(sep) 327function! ExpandSelectionBySearch(sep)
325 if g:search_not_in_register == 1 328 if g:search_not_in_register
326 " Save current selection to register s, and keep selection 329 " Save current selection to register s, and keep selection
327 execute 'norm "sygv' 330 execute 'norm "sygv'
328 let g:search_not_in_register = 0 331 let g:search_not_in_register = 0
@@ -331,18 +334,17 @@ function! ExpandSelectionForSearch(sep)
331 " statusline 334 " statusline
332 call feedkeys(a:sep.."\<C-R>s"..a:sep.."e\<CR>") 335 call feedkeys(a:sep.."\<C-R>s"..a:sep.."e\<CR>")
333endfunction 336endfunction
334function! SubstituteForSearch() 337function! SubstituteBySearch()
335 " Apply current for default substitute text 338 " Apply current search for default substitute text
336 call feedkeys(":s//\<C-R>s/g\<Left>\<Left>") 339 call feedkeys(":s//\<C-R>s/g\<Left>\<Left>")
337endfunction 340endfunction
338vnoremap <TAB> <Cmd>call ExpandSelectionForSearch('/')<CR> 341vnoremap <TAB> <Cmd>call ExpandSelectionBySearch('/')<CR>
339vnoremap <S-TAB> <Cmd>call ExpandSelectionForSearch('?')<CR> 342vnoremap <S-TAB> <Cmd>call ExpandSelectionBySearch('?')<CR>
340vnoremap <CR> <Cmd>call SubstituteForSearch()<CR> 343vnoremap <CR> <Cmd>call SubstituteBySearch()<CR>
341" When leaving visual mode, resume search_not_in_register 344" When leaving visual mode, resume search_not_in_register
342autocmd Modechanged [vV\x16]*:* let g:search_not_in_register = 1 345autocmd Modechanged [vV\x16]*:* let g:search_not_in_register = 1
343 346
344 347
345
346"---------------------------------------------------------------------- 348"----------------------------------------------------------------------
347" Markdown items (temproray solution) 349" Markdown items (temproray solution)
348"---------------------------------------------------------------------- 350"----------------------------------------------------------------------