5

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

1 Answers1

1

You can try temporarily (or permanently) setting 'shellxquote' to a single quote character, like :set shellxquote=\"

Note this will break some external commands using special characters like &, |, <, >, etc. (all the stuff in shellxescape by default), so you may need to not leave it at that value. But, it looks like this is one place where the default shellxquote value from Vim 7.3.450 is broken.

Ben
  • 2,299
  • 20
  • 19