On Vim 7.3 on Windows, if I use Tab to autocomplete paths with nonstandard characters in many cases, it works fine. For example:
:n 2016\ Posts\\feb\something.txt
If I press Tab after '2' and 'f' and "so", I get the above, and it correctly opens "2016 Posts/feb/something.txt". The fact that Windows likes backslashes and the weirdness of escaping them (why does it use it for the space and the first slash, but not the second) does not appear to give Vim a problem. I can even type
/g instead of
\g and Vim properly replaces the forward slash with a backward one.
However, if I try to use run a shell command with
:r!, trouble ensues. For instance, say I want to read in the file listing of "2016 Posts", and I tab after '2' as before:
:r!dir 2016\ Posts\
I get "shell returned 1", and the text I read in is "The system cannot find the file specified."
This makes sense if I imagine Vim is sending the string exactly as I see it to an MS-DOS shell; if I start an actual shell and type "dir 2016\ Posts\" I get the exact same error (and I assume the command is returning error code 1). And if I carefully type:
:r!dir "2016 Posts"
I get the file listing I expect. But I can't use auto-complete.
Is there a way to get Vim to recognize that I'm typing something that will get sent to a shell (with idiosyncratic parsing of slashes, nonstandard characters, and so on), and auto-complete correctly? Or is this an actual bug I should be submitting to Bram Moolenaar? Or, is there some reason this can never be fixed, due to something I hadn't thought of, where Vim can't reasonably tell what I will want? (It seems possible to assume that since I'm using auto-complete, that it's a path, and that since it's inside a
:! construction, that it ought to follow Windows' conventions.)