Maciej Kalisiak wrote:
Thanks for a meaty reply Tony, plenty for me to read up on.

Just one minor related issue: what is the convention of handling "~"
in Vim under Windows?  The problem is that under WinXP, when I use
$HOME in Vim, it gets translated to "~" (i.e., the Unix convention for
home directory), rather than the full absolute path.  Yet at the same
time it seems to me that Vim does not treat "~" as a home directory
here, as :find does not find stuff if my path is set to "~/src" (which
I originally set to "$HOME/src").  Since there are no spaces in
"~/src", I don't think there's any escaping to do, hence this
should've worked if Vim internally expanded out the tilde.

Oh, one other minor one: under Windows, are "\" and "/" *always*
interchangeable in Vim as path seperators, or are there instances
where you must use the Windows backslash convention? I ask because I
thought I read in the manual that they are interchangeable, yet having
exchanged them I was seeing different results.  I suspect the issue
was my improper escaping of the backslashes, but I'd like to eliminate
this one potential source of error before going on to debug...
[...]

For internal use, Vim for Windows can use either '\' or '/' as path separators, or even both of them in the same path. However, '\' is also sometimes used to escape characters which would otherwise have a "separator" meaning. This depends on context. When Vim knows that some value is a file/folder name, it will usually interpret any of '/', '\' or '\\' as a path separator, to be passed to the OS as a single backslash, except where a backslash is obviously meant as an escape prefix. As a general rule, single-quoted strings are used literally while backslashes in double-quoted strings or (as in :set) in unquoted strings are usually meant as escape characters. When a single string is interpreted repeatedly before being used, it may be necessary to double the backslashes as many times as there are "passes".

see
        :help dos-backslash
        :help option-backslash
        :help filename-backslash

For internal use also, Vim uses $NAME to designate environment variables, and ~ (at the start of a path) as a synonym for $HOME, like Unix and not like Dos.

When paths are to be passed to a Dos/Windows program, including but not limited to the shell (COMMAND.COM or cmd.exe), they are to be expressed according to Dos/Windows conventions, with only '\' as path separators, and possibly with double-quoting if spaces within the path would otherwise cause premature termination of the string. With the default settings of the relevant options, Vim is usually clever enough to pass the right value, but it may err in borderline cases.

When environment variables or the name of a home directory are to be passed to a Dos/Windows program, Vim usually passes the value, not the name; however if you want to pass the name for evaluation by a Dos shell you must use %NAME%, not $NAME and not ~, because that is the Dos convention.


Best regards,
Tony.

Reply via email to