Problem
How do I get vim to treat a file extension as an html file?
Because I’m working with an ez template, the file’s extension is.ezt. However, the majority of it is standard HTML code.
Asked by Karthick
Solution #1
:set syntax=html
Answered by Amber
Solution #2
This can also be included to your.vimrc file:
au BufReadPost *.ezt set syntax=html
Answered by Benoit
Solution #3
Take a look at this wikia topic about Vim. Here are some helpful hints:
Answered by slm
Solution #4
Add the following line to your /.vimrc to make it automatic:
autocmd BufNewFile,BufRead *.ezt set filetype=html
If you only want to do it for this particular file, type:
:set filetype=html
You could use syntax instead of filetype, but filetype affects more than just syntax (including syntax highlighting, indenting rules, and plugins), so unless you simply want to change syntax, you should use filetype.
Answered by wisbucky
Solution #5
It’s worth noting that:set syntax=xml highlights correctly but fails when attempting to autoindent the file (by running gg=G).
The highlighting and indentation of the file improved when I moved to:set filetype=xml.
Answered by Daniel
Post is based on https://stackoverflow.com/questions/3853028/how-to-force-vim-to-syntax-highlight-a-file-as-html