Enable syntax highlighting for various filetypes in vim

vim

I can enable syntax highlighting for a file that has an extension that is unknown to vim by doing the following

set syntax=c

Every time I switch tabs however, I have to renter the command. Is there any way to let vim know that a file with an extension .xyz should be coloured with C syntax?

Best Answer

Put this at the end of your .vimrc (I'm assuming you have autocommands enabled).

autocmd BufRead,BufNewFile *.xmlx set filetype=xml
Related Topic