User Tools

Site Tools


blog:adding_syntax_custom_extensions_to_vim

This is an old revision of the document!


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

Enter your comment. Wiki syntax is allowed:
 ______   __    __ __   ___    ____
/_  __/  / /   / //_/  / _ \  / __/
 / /    / /__ / ,<    / , _/ / _/  
/_/    /____//_/|_|  /_/|_| /___/
 
blog/adding_syntax_custom_extensions_to_vim.1247991031.txt.gz · Last modified: 2009-07-19 10:10 by brb