vim

Drupal/Vim users, highlight your .module files

I live in Vim, but finally got tired of editing my .module files without syntax highlighting - ugh. Turns out all you have to do is tell vim what the file is so that it knows what to shade.

Make sure that the following is in your vimrc file - notice the filetype on line:

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
filetype on
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif

Then place the following in ~/.vim/filetype.vim, restart Vim and you are all set!

"  ~/.vim/filetype.vim
" tell Vim what a .module file is
if exists("did_load_filetypes")
  finish
endif
augroup filetypedetect
  au! BufRead,BufNewFile *.module               setfiletype php
augroup END

Syndicate content
My name is Kevin. I am a software engineer and bike geek living in Salem, Mass. I use Vim even when I don't need to. When I'm not on the computer, I'm usually hanging with my wife, Melissa and baby Benjamin or working on my pet project BIKENE.WS.