3

Using Windows 10. I have gvim installed. I also have git, and I have git's bin in my PATH (C:\program files (x86)\Git\bin), which puts git's gnu grep in my path so I can use it in the command shell.

> grep -V
grep (GNU grep) 2.4.2 

However, when I use grep from vim -

:grep -ir 'something' .

It is using FINDSTR in windows, which doesn't work very well.

How do I make gvim use the GNU grep? I tried pre-pending the git bin dir to my vim path but that didn't help.

5
  • Have you tried the grep.vim : Grep search tools integration with Vim plugin?
    – DavidPostill
    Jan 13, 2016 at 23:25
  • thanks for pointing that out. that may be the answer, but I'd like to just try getting the grep command use gnu grep rather than an uppercase Grep command.
    – user39160
    Jan 13, 2016 at 23:37
  • You could always install Cygwin ;)
    – DavidPostill
    Jan 13, 2016 at 23:42
  • 1
    Did you read :help grepprg?
    – romainl
    Jan 14, 2016 at 12:49
  • @romainl - wow I'll have to set aside half a day to do that ;) one of the longest docs I've seen. Looks like it's probably the answer though
    – user39160
    Jan 14, 2016 at 15:27

1 Answer 1

2

The external executable for :grep is controlled by the 'grepprg' option, and on Windows, this defaults to findstr, as :help 'grepprg' details:

For Win32, the default is "findstr /n" if "findstr.exe" can be found, otherwise it's "grep -n".

So, just put the following into your ~/.vimrc:

set grepprg=grep\ -nH
1
  • 1
    The backslash escapes the space character; this is necessary for :set. Jan 18, 2016 at 7:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .