Maciej Kalisiak wrote:
I'm under Windows XP, and I'm having a devil of a time trying to set
'path' to a bunch of directories in my home directory.  My $HOME (and
thus presumably "~") point at c:\Documents and Settings\User\My
Documents\Home.  Doing something like
 set path=$HOME/src
does not work (e.g., ":find" does not find files that are there).
I've tried many variations, even expanding out $HOME in various forms,
and the single variation I have gotten to work was
 let &path='c:\Documents\ and\ Settings\User\My\ Documents\Home\src\'
IIRC, using forward slashes breaks this, using ":set path" instead of
":let &path" breaks this, using ~ or $HOME breaks this, etc.  Also,
with this form I can't seem to be able to later do "let
&path+='c:\....'. (I get E734)  Is there an easier way to set 'path'
in Windows??  I'd like to add something like 5 to 10 directories to
path, and this form is soooo unwieldly and ugly...



        :let escaped_home = escape(substitute($HOME,'/','\\',''),' ')
        :let &path = escaped_home . '\src'
        :let &path .= ',' . escaped_home . '\include'
etc.

See under ":help 'path'", the paragraph starting "Spaces can also" about using the ":set" command to set a 'path' with spaces in it. ":set option=foo\\\ bar" is equivalent to ":let &option = 'foo\ bar'". If $HOME contains spaces, you must backslash-escape them, either manually like you did, or by using the escape() function as shown above.

Alternately, you can use the short name of the $HOME directory, which has no spaces in it (because spaces are forbidden in short names):

        :let short_home = 'C:\DOCUME~1\User\MYDOCU~1\Home'
        :exe "set path=" . short_home . '\src'
        :exe "set path+=" . short_home . '\include'
etc.

Note the difference between single and double quotes in Vim: 'foo\ bar' is equivalent to "foo\\ bar" and its value has one backslash in it.


Best regards,
Tony.

Reply via email to