← Back to Upcase

Searching a project with silver searcher

(Brian Dear) #1

Really basic question:

How do I search a project with Silver Searcher from within vim? In the old days when I used Sublime, it was a simple command-shift-f, but in the Vim world, nothing is simple for us newcomers.

(Josh Steiner) #2

Install https://github.com/epmatsw/ag.vim. Then you can search with :Ag.

(Jon Yurek) #3

I like to use ag as my grepprg.

cnoreabbrev ag grep
if executable("ag")
  set grepprg=ag\ --nogroup\ --nocolor\ --column

Then a command like :grep initialize will use ag instead of grep.

You might also want this which will automatically open the search results in the QuickFix window:

autocmd QuickFixCmdPost *grep* cwindow

Some (or all) of this might be available from ag.vim, but, personally, I don’t see the point of adding more plugins than I have to, and these commands work perfectly well for my purposes.