Getting vim to recognize a new file extension as an existing file type

For global configuration, add this to /etc/vim/filetype.vim, for just you, add to ~/.vim/filetype.vim :

if exists("did_load_filetypes")
    finish
endif
" add .ctp and .thml as recognized php file extensions (good for CakePHP)
augroup filetypedetect
    au! BufNewFile,BufRead *.ctp,*.thml     setf php
augroup END

In this example, I’m getting vim to recognize .ctp and .thtml files as PHP. Both extensions are used by CakePHP.

The vim documentation has full explanation of how to add and configure file types.

social bookmark of choice:
  • Digg
  • del.icio.us
  • Ma.gnolia
  • Reddit
  • Slashdot

Leave a Reply