Suppose I've written a new syntax file for vim, for some file type, and I now want to integrate it into vim (8.1). I'm looking at /usr/share/vim/vim81/filetypes.vim, and I'm noticing some lines have the form:
au BufNewFile,BufRead *.ext setf foo
For some extension .ext and syntax file syntax/foo.vim. But some lines have something else:
au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst,*.ptx call dist#ft#FTasm()
or
au BufNewFile,BufRead proftpd.conf* call s:StarSetf('apachestyle')
Why this difference? And which should I be using?
:setf foois a pretty simple command that sets the filetype of the current buffer tofooif it wasn't already set.The authors of the scripts you quote probably have other needs, or they may have to perform more checks or whatever, so they decided to encapsulate all that stuff in custom functions, which are called with
:call FunctionName().So…
See
:help :setfand:help :call.