For some reason I can't for the life of me figure out how to pass single quotation marks to external tools when using vim. For example, I might want to call Vim's external grep to search for the text "foo (that is, a single quotation mark then the word foo)
So I might try the command:
:grep \"foo *.txt
But this results in the following error message:
!findstr /n \"foo *.txt >C:\Users\[username]\AppData\Local\Temp\VIeC244.tmp 2>&1
shell returned 1
E40: Can't open errorfile C:\Users\[username]\AppData\Local\Temp\VIeC244.tmp
Note that grep is changed to use 'findstr /n' since I'm on windows (and can be verified by running echo &grepprg
). What I find is that I can easily execute the search I want if I do it myself from the command line by typing the following:
findstr /n \"foo *.txt
Which works exactly as I'd expect
\\\"
? I can only assume that vim unescapes the parameter(s) given to:grep
and callsfindstr /n "foo *.txt
- which would of course be an invalid command and cause an error.:!findstr /n \"foo *.txt
? If that fails, your working directory (try:pwd
) might not be set to what you would expect, so*.txt
won't find anything. (By default, Vim doesn't automatically change the working directory to the directory of the current file).set autochdir