I have the following command in my vimrc:
execute "set path+=".getcwd()."/**"
It works well if current working directory is like /home/tamlok/my_work/
. However, if the directory contains spaces, such as D:\Program Files\vim\
, vim will complain.
I suppose that I can fix this using substitute()
function to replace all the spaces with escaped spaces. What would an experienced vimmer do here?
Another issue is the \
in Windows. If getcwd()
gets D:\Program Files\vim\
, do I need to escape the \
with \\
or replace it with /
?
For now I handle it like this:
let mycwd=substitute(getcwd(), '\\', '/', 'g')
let mycwd=substitute(mycwd, ' ', '\\ ', 'g')
execute "set path+=".mycwd."/**"
Is that OK? Any help is appreciated! Thanks very much!