VIM: Set filetype for different extensions

I love VIM. It is my primary editor for nearly all text processing and my programming. But sometimes configuring Vim can be a pain in the ass. Specifically, I have some html templates for an application I am writing using bottle.py. A wonderful micro web framework if you are looking. An entire framework in a single file import, but I digress.

The html templates use the file extension .tpl, but are html code so I want to apply my Vim html settings to them. After some digging I came up with

1
au BufRead,BufNewFile *.tpl set filetype=html

This will force Vim to set any file with the .tpl file extension to the filetype of html, which in turn will make it use my html.vim settings.

Leave a Reply

Your email address will not be published. Required fields are marked *