aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2014-05-24 20:50:43 -0400
committerTeddy Wing2014-05-24 20:50:43 -0400
commit1ea665202290ecac6738e4134396b2509da4f5e2 (patch)
treeb52bcd553f588acfab249c5208d105a3bda54c10
parent6f365a80a78952ad2c6488365f4f6094b9a57051 (diff)
downloaddotvim-1ea665202290ecac6738e4134396b2509da4f5e2.tar.bz2
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 <leader>*. Allows text in the current visual selection to be searched for as you would a word with # and *.
-rw-r--r--plugin/vsearch.vim15
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>