blog:adding_syntax_custom_extensions_to_vim

Adding syntax custom extensions to vim

I'm currently working with cakePHP (a great framework for implementing web-base PHP/Database/Ajax solutions). For that, wanted to enable php syntax highlighting to *.ctp files (View Files).

This is easy, just add the following line to you ~/.vimrc file:

au BufNewFile,BufRead *.ctp set filetype=php

How and why this works, you find in the vim help:

:help au :au[tocmd] [group] {event} {pat} [nested] {cmd}
Add {cmd} to the list of commands that Vim will execute automatically on {event} for a file matching {pat}.
:help BufNewFile When starting to edit a file that doesn't exist.
:help BufRead When starting to edit a new buffer, after reading the file into the buffer.
:help filetype will actually tell this whole story in part B.

Source: http://beerpla.net/2008/04/02/how-to-add-a-vim-file-extension-to-syntax-highlighting/

~~LINKBACK~~ ~~DISCUSSION~~

  • blog/adding_syntax_custom_extensions_to_vim.txt
  • Last modified: 2009/07/19 10:11
  • by brb