I would like to use an external grep for my vim grep searches. So I have this in my _vimrc:
se grepprg=c:/cygwin/bin/grep.exe
Now I do
:grep XYZ *.c
Now I would like to look at the result of the grep in a quickfix window. But if I do
:cwindow
a quckfix window is not opened. If I instead do :copen, then I do see the grep result. But each line in the result is prepended with ‘||’ like this:
|| foo.c:line that contains XYZ
|| bar.c:and another line that contains XYX
I can’t seem to open the files by selecting them from the :copen window (put cursor on them and type <CR>). Are the ||’s the problem? Does it mess up grepformat?
What causes the ||’s to appear? If I run c:/cygwin/bin/grep.exe outside of vim I do not get them. If I do not set grepprg then the default for grepprg is findstr.exe. In that case, I do not get the ||’s. If I set grepprg to findstr.exe, then I do get the ||’s.
Greg
Greg
The problem is that you forgot to include the -n argument as part of
grepprg. That is, you should set greprg like this:
:set grepprg=c:/cygwin/bin/grep.exe\ -n
See
:help grepprg
Regards,
Gary