How to set a parameter using let for the current buffer (vim)?

In vimlanguage, you can only set parameters for the current buffer using setlocal . However, I need to set a more complex expression than just a literal, which is not possible with setlocal .

I currently have let &formatprg=s:prgpath." ".a:args , but this sets formatprg for all buffers, which I don't want. How can I set formatprg as above only for the current buffer?

+4
source share
2 answers

Use let &l:option instead of let &option to change only the local value, such as setlocal option . Similarly, let &g:option will set a global value, such as the setglobal option . See :help :let-option more details.

Note that formatprg is particularly global (there is no "local to buffer" in its help ).

+10
source

Creating a global buffer-local parameter requires changes to the Vim source code. Alternatively, I just published a GlobalOptions plugin that uses autocmds to get around this, and turns any global option into a buffer or window local one.

+1
source

All Articles