I understand that VIM makes a difference between set
and setl
in that the first one sets an option for all buffers while the latter one sets the option fur the current buffer only. This is evident if I have do a :set tw=80
as opposed to a :setl tw=80
.
Now, when I do a :set ft=plsql
, it only opperates on the current buffer although I did not do a setl
. This, of course, makes sense. Yet, 开发者_开发技巧I fail to see if this is documented somewhere. So, the question probably boils down to: are there options that by default operate on the current buffer while others operate "everywhere" and where is that documented?
There are indeed options that operate on the current buffer (and indeed the current window in some cases). The documentation is with the documentation for the option. If you go to any option in :help option-list
, it will have one of the following three strings as the third-ish line:
global
local to window
local to buffer
(or some combination of them). For example, :help 'ft'
gives:
*'filetype'* *'ft'*
'filetype' 'ft' string (default: "")
local to buffer
{not in Vi}
{not available when compiled without the |+autocmd|
feature}
When this option is set, the FileType autocommand event is triggered.
All autocommands that match with the value of this option will be
executed. Thus the value of 'filetype' is used in place of the file
name.
So this option is local to the buffer. For more discussion, see:
:help option-summary
When you read a new buffer in vim, or move from one buffer to another, vim triggers the equivalent of BufEnter
, which re-evaluates the filetype of the file in that buffer. You could potentially override this behavior by blowing away your ftdetect
directory in ~/.vim and replacing it with a file containing only au BufRead,BufNewFile,BufEnter * set filetype=plsql
, at which point all files would be read as SQL. If you were to unset all filetype detections, the autocommand would never trigger.
精彩评论