In my file system, I have some files which start with a plus sign. When I try to open these with vim an error is thrown.
For example, when typing...
vim +foo.outI get the following error...
Error detected while processing command line:
E492: Not an editor command: foo.outI can see that vim thinks that since there is a plus sign, I must be trying to run some kind of command, but since it's followed by a filename it doesn't know what to do. Any suggestions on how I get around this and open/edit the files?
01 Answer
Yes, vim does not interpret +foo.out as a filename. There are at least two solutions:
Make the argument look like an absolute or relative path, so it doesn't start with
+or-. In this casevim ./+foo.outIn general this is useful when the argument is a filename. If it's not (e.g.
grep -string-to-find) then you need to use another method.Inform the tool when it should stop parsing options. A common way is to use a double dash. In this case it will be
vim -- +foo.outIn general this is useful when the tool supports this meaning of
--. Vim does, many tools do (note: supporting--is one of the POSIX guidelines); but some don't.
If each method can be used then using them both is kinda excessive but by no means an error:
vim -- ./+foo.out