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?
Use
let &l:optioninstead oflet &optionto only change the local value, likesetlocal option. Similarly,let &g:optionwould only set the global value, likesetglobal option. See:help :let-optionfor more information.Note that
formatprgin particular is global (no “local to buffer” in its help).