Search code examples
vimgrep

Greping from within Vim (with a pipe)


I want to create a 'quickfix' list (see :help quickfix) with all files that contain lines with "abc" but not "xyz". I was hoping I could run the following vim ex command:

:grep -nHr abc * | grep -v xyz

Unfortunately, vim doesn't like the "pipe" and the command fails. What is the best way to do this from within vim?


Solution

  • For some reason I can't leave this one alone!

    How about use :!grep ... > filename followed by :cf filename, which will open the output as a quickfix list.