aboutsummaryrefslogtreecommitdiffhomepage
path: root/vim/init
diff options
context:
space:
mode:
Diffstat (limited to 'vim/init')
-rw-r--r--vim/init/keymaps.vim34
1 files changed, 21 insertions, 13 deletions
diff --git a/vim/init/keymaps.vim b/vim/init/keymaps.vim
index 5441f32..eca23f9 100644
--- a/vim/init/keymaps.vim
+++ b/vim/init/keymaps.vim
@@ -88,7 +88,7 @@ nnoremap cd :cd %:p:h<CR>:pwd<CR>
88" Switch CDW to root git directory 88" Switch CDW to root git directory
89nnoremap cdg :execute 'cd' fnameescape(fnamemodify(finddir('.git', escape(expand('%:p:h'), ' ') . ';'), ':h'))<CR>:pwd<CR> 89nnoremap cdg :execute 'cd' fnameescape(fnamemodify(finddir('.git', escape(expand('%:p:h'), ' ') . ';'), ':h'))<CR>:pwd<CR>
90" alias for cd 90" alias for cd
91nnoremap cd<space> :cd<space> 91nnoremap cdd :cd<space>
92nnoremap cd.. :cd .. <CR>:pwd<CR> 92nnoremap cd.. :cd .. <CR>:pwd<CR>
93nnoremap cd... :cd ../.. <CR>:pwd<CR> 93nnoremap cd... :cd ../.. <CR>:pwd<CR>
94 94
@@ -317,22 +317,30 @@ endfunction
317 317
318command! -nargs=1 -complete=command Redir silent call Redir(<q-args>) 318command! -nargs=1 -complete=command Redir silent call Redir(<q-args>)
319nnoremap <leader>rr :Redir<space> 319nnoremap <leader>rr :Redir<space>
320
321
322"---------------------------------------------------------------------- 320"----------------------------------------------------------------------
323" QUICK_SUBSTITUTE 321" QUICK_SUBSTITUTE
324"---------------------------------------------------------------------- 322" Press <TAB> n times for area, and <CR> for substitute
325let g:text_selected = 1 323let g:search_not_in_register = 1
326function! SelectAreaOrDoSubstitute() 324function! ExpandSelectionForSearch(sep)
327 if g:text_selected 325 if g:search_not_in_register == 1
328 call feedkeys("\"sygv/\<C-R>s\<CR>gn") 326 " Save current selection to register s, and keep selection
329 let g:text_selected = 0 327 execute 'norm "sygv'
330 else 328 let g:search_not_in_register = 0
331 call feedkeys(":s//\<C-R>//g\<Left>\<Left>")
332 let g:text_selected = 1
333 endif 329 endif
330 " Use register s to go to next search, counts/total is displayed in
331 " statusline
332 call feedkeys(a:sep.."\<C-R>s"..a:sep.."e\<CR>")
333endfunction
334function! SubstituteForSearch()
335 " Apply current for default substitute text
336 call feedkeys(":s//\<C-R>s/g\<Left>\<Left>")
334endfunction 337endfunction
335vnoremap <TAB> <Cmd>call SelectAreaOrDoSubstitute()<CR> 338vnoremap <TAB> <Cmd>call ExpandSelectionForSearch('/')<CR>
339vnoremap <S-TAB> <Cmd>call ExpandSelectionForSearch('?')<CR>
340vnoremap <CR> <Cmd>call SubstituteForSearch()<CR>
341" When leaving visual mode, resume search_not_in_register
342autocmd Modechanged [vV\x16]*:* let g:search_not_in_register = 1
343
336 344
337 345
338"---------------------------------------------------------------------- 346"----------------------------------------------------------------------