Reputation: 5615
I'm using Gvim 7.4 in Windows 7 x64. When I grep for anything, I get the error:
FINDSTR: Cannot open System32
I've looked it up and found this question. I think my situation is different. I don't know what's causing the error. I don't want to use the internal grep in vim. I either want findstr or just normal grep (The answer didn't cover setting up the external grep, it just mentioned that it's doable) From what I understood (correct me if I'm wrong) when I do grep in vim, it locates whatever it is my OS's searching tool and uses that instead. So I should be good to go using findstr, why isn't it working?
I eventually gave up on findstr and installed UnxUtils to C:\Linux
But I couldn't figure out how to set vim's external grepping tool to use C:\Linux\grep.exe
- I know it has to do with grepprg
but I'm not sure how, I tried setting it directly set grepprg="C:/Linux/grep.exe"
(or grep.exe -n
for that matter - with and without the .exe
) but that didn't work, every time I grep for something like grep someString .
it says someString is not recognized as an internal or external command
. The doc is a big vague on the subject. How can I set vim's external grep to my installed one?
Thanks.
EDIT:
I also tried adding the 'grep.exe' to one of my $PATH
directories (system32) - and do set grepprg=grep\ -nH
but now when I grep it says grep is not recognized as an internal or external command
Upvotes: 0
Views: 986
Reputation: 8905
It sounds like your 64-bit System32 directory is where findstr lives, but if you're running a 32-bit Vim, it won't actually see that directory. Instead it sees the c:\windows\Syswow64 directory due to a feature of Windows. But you can probably force Vim to look in the "real" System32 folder, by adding it to your path in your .vimrc:
let $PATH.=';C:\Windows\Sysnative'
Upvotes: 1
Reputation: 5615
So I had to copy grep.exe to my Vim installation/Vim74
instead ofC:/Windows/system32
and also do set grepprg=grep\ -nH
Upvotes: 0