Vim/Ag: files whitelist in AgFromSearch

166 views Asked by At

I am using vim with Ag.vim(silver-searcher) and i came across a problem.

the Ag plugin defines Ex mode commands such as :Ag and :AgFromSearch. but while :Ag lets me pass options to the shell's ag command such as -G which lets me whitelist files, :AgFromSearch doesn't let me..

so my question is - is there any pretty solution to this? or should i just imitate the way the plugin implements :AgFromSearch with :Ag and pass through it the options?

1

There are 1 answers

0
gregory On BEST ANSWER

Ag.vim is deprecated; you should consider moving back to using Ack.vim. The maintainer of Ack.vim is open to supporting the Ag community.

The :AckFromSearch allows for passing extra options like the -G. You first must configure the Ack.vim to use Ag, by adding this to .vimrc:

let g:ackprg = 'ag --vimgrep' 

And, then you can do :AckFromSearch like the following:

:AckFromSearch -G '.*py' 

Since moving back to the Ack.vim plugin, I use this feature quite frequently and have mapped ,* to :AgFromSearch in vim.