In a line like autocmd InsertEnter <buffer> setlocal foo=bar
, are <buffer>
and setlocal
redundant? What are the functional differences between each of the following?
autocmd InsertEnter <buffer> setlocal foo=bar
autocmd InsertEnter <buffer> set foo=bar
autocmd InsertEnter setlocal foo=bar
autocmd InsertEnter set foo=bar
Also, is there any difference between using set
and setlocal
on settings that are "local to window" or "local to buffer" rather than global?
<buffer>
on autocommands only serves to define an autocommand that applies only on the current buffer at the moment the autocommand is registered. There are events with which it won't make sense (like buffer creation events).
Then, some options are global, some are local to buffers and some are local to windows. To know exactly, you'll have to dig into their documentation. Sometimes we can have global and local settings for an option. However, IIRC and I may be wrong, some options don't have global settings and are always local.
PS: Thanks to you, I've just discovered :set {option}<
. I've been expecting it for a long time, without being aware of its existence... Thanks :)