Persistent :set syntax for a given filetype?

au BufNewFile,BufRead,BufReadPost *.twig set syntax=HTML

And add this line to ~/.vimrc to make the settings persistent.


Add one of the following passages to your .vimrc:

" Set the filetype based on the file's extension, overriding any
" 'filetype' that has already been set
au BufRead,BufNewFile *.html.twig set filetype=html

or

" Set the filetype based on the file's extension, but only if
" 'filetype' has not already been set
au BufRead,BufNewFile *.html.twig setfiletype html

You can use autocmd to accomplish that, i.e.:

augroup twig_ft
  au!
  autocmd BufNewFile,BufRead *.html.twig   set syntax=html
augroup END

Should work.