diff options
| -rw-r--r-- | plugin/vsearch.vim | 15 | 
1 files changed, 15 insertions, 0 deletions
| diff --git a/plugin/vsearch.vim b/plugin/vsearch.vim new file mode 100644 index 0000000..e1472f5 --- /dev/null +++ b/plugin/vsearch.vim @@ -0,0 +1,15 @@ +" vsearch.vim +" Visual mode search +" Copied from https://github.com/godlygeek/vim-files/blob/master/plugin/vsearch.vim +function! s:VSetSearch() +  let temp = @@ +  norm! gvy +  let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g') +  " Use this line instead of the above to match matches spanning across lines +  "let @/ = '\V' . substitute(escape(@@, '\'), '\_s\+', '\\_s\\+', 'g') +  call histadd('/', substitute(@/, '[?/]', '\="\\%d".char2nr(submatch(0))', 'g')) +  let @@ = temp +endfunction + +vnoremap * :<C-u>call <SID>VSetSearch()<CR>/<CR> +vnoremap # :<C-u>call <SID>VSetSearch()<CR>?<CR> | 
