Literally the only working solution I have found for this issueIt is using Lua instead of Vimscript, because apparently such esoteric, advanced operations as escaping spaces in command arguments are only availableperhaps easiest to Level 999 Vimscript Wizards. To accomplishdo this with Lua. If you use neovim, you can either port over your entire init.vim
file to Lua and save it as init.lua
instead (nvim will load from one or the other, but throw an error about conflicting configs if you try to load from both). In Vim with +lua
or neovim, you could instead use one lua command in your vimscript file, like so:
:lua vim.opt.path = '/c/Program Files/exampledir'
Edit: Vimscript fix
:lua vim.opt.path = '/c/Program Files/exampledir'
As a comment pointed out, there is amore information at :help 'path'
command available. This actually does provide part of the answer to this question (the commenter was too arrogant to provide it directly): that spaces and backslashes should be BOTHboth be backslash-escaped to work. The other issue with all the examples I was trying is thatAlso, the =
sign in the expressions will fail if there are any adjacent spaces, so a fully working Vimscript answer looks like:
:set path=/c/Program\\\
can be preceded but not followed by space (:help Files/exampledir:set=
):
Edit: Using Expressions
set path=/c/Program\\\ Files/exampledir
As per another comment, there is a way to set the option with an expression, which allows more straightforward quoting:
let &path='/c/Program Files/exampledir'
let &path='/c/Program Files/exampledir'