From 1ea665202290ecac6738e4134396b2509da4f5e2 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 24 May 2014 20:50:43 -0400 Subject: Add vsearch plugin for visual # & * search Copied from https://github.com/godlygeek/vim-files/blob/master/plugin/vsearch.vim which resembles https://github.com/bronson/vim-visual-star-search but uses the # and * keys directly instead of *. Allows text in the current visual selection to be searched for as you would a word with # and *. --- plugin/vsearch.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 plugin/vsearch.vim (limited to 'plugin') 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 * :call VSetSearch()/ +vnoremap # :call VSetSearch()? -- cgit v1.2.3