I'm new to Vim and am trying to figure out project-wide searching. Following Practical Vim and a Thoughbot post, I've tried using ack instead of grep and then The Silver Searcher instead of ack by putting this in my vimrc
When trying to use ack (following Practical Vim):
set grepprg=ack\ --nogroup\ $* "Use ack instead of grep
set grepformat=%f:%l:%c:%m
When trying to use The Silver Searcher (following Thoughtbot):
set grepprg=ag\ --nogroup\ --nocolor
set grepformat=%f:%l:%c:%m
In both cases when I search for something, say :grep RSpec
, the list of results comes up. I enter :copen
to open the Quickfix List. However, vim doesn't open the first match and when I press enter on a match in the Quickfix List it does nothing. :cnext
, :cprev
, etc. also do nothing. The Quickfix List also has ||
preceding each match.
When I try :vimgrep RSpec **/*.rb
the results are displayed, I enter :copen
, the first match is displayed in a buffer, and when I press enter on any of the other matches, they open in the buffer as expected.
Any help in figuring out how to correct this would be greatly appreciated.
remove your grepformat
setting and use the default, the default value should work with ag
and ack
check the meaning of fields in grepforamt
by :h errorformat
, your ag/grep output doesn't follow the format you defined, so that :grep cannot parse the output.