I noticed that in order for Vim to color highlight the syntax of a specific file, one can both set the following in the _vimrc file:
au BufNewFile,BufRead *.file_extension set filetype=program_highlighting
au BufNewFile,BufRead *.file_extension set syntax=program_highlighting
What is the difference between using filetype=
or syntax=
?
The 'filetype'
is a superset of 'syntax'
.
With 'filetype'
(assuming you have :filetype plugin on
configured), you also load filetype plugins and their corresponding settings (e.g. indent config, compiler, mappings) from the ftplugin
configuration subdir, in addition to setting the syntax to the filetype name.
That last part is done automatically by Vim as part of the filetype processing, in $VIMRUNTIME/syntax/syntax.vim
:
au! FileType * exe "set syntax=" . expand("<amatch>")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With