" From http://got-ravings.blogspot.com/2008/07/vim-pr0n-visual-search-mappings.html " makes * and # work on visual mode too. function! s:VSetSearch(cmdtype) let temp = @s norm! gv"sy let @/ = '\V' . substitute(escape(@s, a:cmdtype.'\'), '\n', '\\n', 'g') let @s = temp endfunction xnoremap * :call VSetSearch('/')/=@/ xnoremap # :call VSetSearch('?')?=@/ " recursively vimgrep for word under cursor or selection if you hit leader-star nmap * :execute 'noautocmd vimgrep /\V' . substitute(escape(expand(""), '\'), '\n', '\\n', 'g') . '/ **' vmap * :call VSetSearch():execute 'noautocmd vimgrep /' . @/ . '/ **'