Skip to main content
deleted 418 characters in body
Source Link
D. Ben Knoble
  • 27.7k
  • 3
  • 31
  • 68

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'

Literally the only working solution I have found for this issue is using Lua instead of Vimscript, because apparently such esoteric, advanced operations as escaping spaces in command arguments are only available to Level 999 Vimscript Wizards. To accomplish this, 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) or use one lua command in your vimscript file, like so:

:lua vim.opt.path = '/c/Program Files/exampledir'

Edit: Vimscript fix

As a comment pointed out, there is a :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 BOTH be backslash-escaped to work. The other issue with all the examples I was trying is that 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\\\ Files/exampledir

Edit: Using Expressions

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'

It is perhaps easiest to do this with Lua. If you use neovim, you can 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'

As a comment pointed out, there is more information at :help 'path': spaces and backslashes should be both be backslash-escaped to work. Also, the = in :set can be preceded but not followed by space (:help :set=):

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'
added 198 characters in body
Source Link

Literally the only working solution I have found for this issue is using Lua instead of Vimscript, because apparently such esoteric, advanced operations as escaping spaces in command arguments are only available to Level 999 Vimscript Wizards. To accomplish this, 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) or use one lua command in your vimscript file, like so:

:lua vim.opt.path = '/c/Program Files/exampledir'

Edit: Vimscript fix

As a comment pointed out, there is a :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 BOTH be backslash-escaped to work. The other issue with all the examples I was trying is that 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\\\ Files/exampledir

Edit: Using Expressions

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'

Literally the only working solution I have found for this issue is using Lua instead of Vimscript, because apparently such esoteric, advanced operations as escaping spaces in command arguments are only available to Level 999 Vimscript Wizards. To accomplish this, 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) or use one lua command in your vimscript file, like so:

:lua vim.opt.path = '/c/Program Files/exampledir'

Edit: Vimscript fix

As a comment pointed out, there is a :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 BOTH be backslash-escaped to work. The other issue with all the examples I was trying is that 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\\\ Files/exampledir

Literally the only working solution I have found for this issue is using Lua instead of Vimscript, because apparently such esoteric, advanced operations as escaping spaces in command arguments are only available to Level 999 Vimscript Wizards. To accomplish this, 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) or use one lua command in your vimscript file, like so:

:lua vim.opt.path = '/c/Program Files/exampledir'

Edit: Vimscript fix

As a comment pointed out, there is a :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 BOTH be backslash-escaped to work. The other issue with all the examples I was trying is that 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\\\ Files/exampledir

Edit: Using Expressions

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'

added 519 characters in body
Source Link

Literally the only working solution I have found for this issue is using Lua instead of Vimscript, because apparently such esoteric, advanced operations as escaping spaces in command arguments are only available to Level 999 Vimscript Wizards. To accomplish this, 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) or use one lua command in your vimscript file, like so:

:lua vim.opt.path = '/c/Program Files/exampledir'

Edit: Vimscript fix

As a comment pointed out, there is a :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 BOTH be backslash-escaped to work. The other issue with all the examples I was trying is that 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\\\ Files/exampledir

Literally the only working solution I have found for this issue is using Lua instead of Vimscript, because apparently such esoteric, advanced operations as escaping spaces in command arguments are only available to Level 999 Vimscript Wizards. To accomplish this, 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) or use one lua command in your vimscript file, like so:

:lua vim.opt.path = '/c/Program Files/exampledir'

Literally the only working solution I have found for this issue is using Lua instead of Vimscript, because apparently such esoteric, advanced operations as escaping spaces in command arguments are only available to Level 999 Vimscript Wizards. To accomplish this, 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) or use one lua command in your vimscript file, like so:

:lua vim.opt.path = '/c/Program Files/exampledir'

Edit: Vimscript fix

As a comment pointed out, there is a :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 BOTH be backslash-escaped to work. The other issue with all the examples I was trying is that 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\\\ Files/exampledir

Source Link
Loading