tags:

views:

30

answers:

3

I try to use vim's internal grep with '**' wildcard as in the following command:

grep "test" **\*.txt

vim gives the following error:

FINDSTR: Cannot open **\*.txt

When I remove the '**' wildcard, the command works properly:

grep "test" *.txt

I changed the backslashes to forward slashes, but it didn't help neither:

grep "test" **\*.txt

This gives the above error again.

What might be the reason?

Note: I use GVim 7.2 on Microsoft Windows XP.

+1  A: 

You should try vimgrep.

Tassos
+2  A: 

Doing a ":grep" in Vim under XP does not use "grep.exe" by default. By default "FINDSTR" is used which is part of the Windows installation. "FINDSTR" is not compatible to grep. Due to this you get the error message

FINDSTR: Cannot open **\*.txt

See ":help grepprg".

If you want to use a Windows port of grep you have to install it since grep is neither part of Windows nor of the Vim installation.

But since 7.0 Vim has an internal grep called vimgrep. See ":help vimgrep" for details.

You have to set 'grepprg' accordingly so that either grep or vimgrep is used (instead of the default FINDSTR).

Habi
Thank you very much. This solved the problem: ":set grepprg=internal"
Mert Nuhoglu
+1  A: 

Install cygwin, mingw, or unxutils to get grep (I use cygwin). Add the bin directory to your PATH.

And like Habi said, add to your vimrc:

set grepprg=grep -nH

(This is what grep on *nix uses by default.)

Also, if you :help grep, you'll get a description of the differences between grep and vimgrep. (Speed vs. portability and flexibility.)

pydave