VIM: difference between set and setl depending on file type

I understand that VIM makes the difference between set and setl in that the former sets the option for all buffers, while the latter sets the option only for the current buffer. This is obvious if I have :set tw=80 , not :setl tw=80 .

Now, when I do :set ft=plsql , it only works in the current buffer, although I did not do setl . That, of course, makes sense. However, I do not see it being documented anywhere. Thus, the question probably boils down to: are there options that by default work with the current buffer, while others work "everywhere" and where is this documented?

+7
source share
2 answers

There are indeed options that work in the current buffer (and indeed in the current window in some cases). The documentation has documentation for this option. If you go to any option in :help option-list , it will have one of the following three lines as the third line:

 global local to window local to buffer 

(or some combination thereof). 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. 

Thus, this parameter is local to the buffer. Further information can be found in the following sections:

 :help option-summary 
+11
source

When you read a new buffer in vim or move from one buffer to another, vim runs the equivalent of BufEnter , which revises the file type in that buffer. You could override this behavior by throwing your ftdetect directory into ~ / .vim and replacing it with a file containing only au BufRead,BufNewFile,BufEnter * set filetype=plsql , after which all files will be read as SQL. If you had to disable all file detection, the auto command will never start.

0
source

All Articles