Browse files

make wordwise \* use vimgrep instead of grep -r

  • Loading branch information...
1 parent 7c71bf2 commit ab4e84491a128485f6bc8b2d6548b725277667af @bronson committed Aug 13, 2010
Showing with 4 additions and 3 deletions.
  1. +4 −3 plugin/visual-star-search.vim
View
7 plugin/visual-star-search.vim
@@ -11,6 +11,7 @@ endfunction
vmap * :<C-u>call <SID>VSetSearch()<CR>//<CR>
vmap # :<C-u>call <SID>VSetSearch()<CR>??<CR>
-" recursively vimgrep if you hit leader-star
-nmap <leader>* :execute "noautocmd grep -rw " . expand("<cword>") . " ."<CR>
-vmap <leader>* :<C-u>call <SID>VSetSearch()<CR>:execute "noautocmd vimgrep /" . @/ . "/ **"<CR>
+" recursively vimgrep for word under cursor or selection if you hit leader-star
+nmap <leader>* :execute 'noautocmd vimgrep /\V' . substitute(escape(expand("<cword>"), '\'), '\n', '\\n', 'g') . '/ **'<CR>
+vmap <leader>* :<C-u>call <SID>VSetSearch()<CR>:execute 'noautocmd vimgrep /' . @/ . '/ **'<CR>
+

0 comments on commit ab4e844

Please sign in to comment.