Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to associate files with existing filetype in Vim

📅 2015-Mar-19 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ filetype, vim ⬩ 📚 Archive

Vim has support for many filetypes. If it detects that a file is of a certain filetype, then syntax highlighting and indenting rules of that filetype are applied to the file.

If you have a new file extension that you want to associate with an existing filetype, that is easy to do in Vim. For example, to associate files of type .foo with the filetype .html, add this line to your .vimrc:

autocmd BufRead,BufNewFile *.foo set filetype=html

For more info, try :help new-filetype in your Vim 😊

Tried with: Vim 7.4 and Ubuntu 14.04