Reputation: 16184
In vimlanguage, you can set options for the current buffer only using setlocal
.
However, I need to set a more complex expression than just a literal, which isn't possible with setlocal
.
I currently have let &formatprg=s:prgpath." ".a:args
, but this sets the formatprg for all buffers, which is not what I want.
How would I set the formatprg like above, only for the current buffer?
Upvotes: 9
Views: 3371
Reputation: 172510
Making a global option buffer-local requires changes to Vim's source code. Alternatively, I've just published the GlobalOptions plugin that uses autocmds to work around this, and turns any global option into a buffer- or window-local one.
Upvotes: 1
Reputation: 5746
Use let &l:option
instead of let &option
to only change the local value, like setlocal option
. Similarly, let &g:option
would only set the global value, like setglobal option
. See :help :let-option
for more information.
Note that formatprg
in particular is global (no "local to buffer" in its help).
Upvotes: 20