Vim:了解本地设置-何时使用缓冲区本地与设置本地?

Vim:了解本地设置-何时使用缓冲区本地与设置本地?,vim,autocmd,Vim,Autocmd,在类似于autocmd InsertEnter setlocal foo=bar的行中,和setlocal是否冗余?以下各项之间的功能差异是什么 autocmd InsertEnter <buffer> setlocal foo=bar autocmd InsertEnter <buffer> set foo=bar autocmd InsertEnter setlocal foo=bar autocmd InsertEnter set foo=bar autoc

在类似于
autocmd InsertEnter setlocal foo=bar的行中,
setlocal
是否冗余?以下各项之间的功能差异是什么

autocmd InsertEnter <buffer> setlocal foo=bar

autocmd InsertEnter <buffer> set foo=bar

autocmd InsertEnter setlocal foo=bar

autocmd InsertEnter set foo=bar
autocmd插入器设置本地foo=bar
autocmd插入器设置foo=bar
autocmd插入器设置本地foo=bar
autocmd插入器设置foo=bar
另外,在“本地到窗口”或“本地到缓冲区”而不是全局的设置上使用
set
setlocal
有什么区别吗?

在自动命令上只用于定义在自动命令注册时仅应用于当前缓冲区的自动命令。有些事件是没有意义的(比如缓冲区创建事件)

然后,有些选项是全局的,有些是缓冲区本地的,有些是windows本地的。要确切地知道,你必须深入研究他们的文档。有时我们可以对一个选项进行全局和本地设置。然而,IIRC和我可能错了,有些选项没有全局设置,并且总是本地的


PS:多亏了你,我才发现
:set{option}这是否意味着在
~/.vimrc
中使用
是没有意义的,除非你(a)只想在编辑
~/.vimrc
时生效,或者(b)在另一个缓冲区中显式地使用
:so~/.vimrc
。(a):是的,就是这样。(b):no
InsertEnter
不应用于当前编辑的缓冲区以外的缓冲区。