Teaching VI to recognize Drupal's *.module as php files

Submitted by boaz on Saturday, July 19, 2008.

This is a blog post for moi, actually. I get into the habit of "I had this piece of info in my blog. Lets recall..." and I'm following this this habbit with the post you're reading. Of course, I do hope its useful for others.

The issue at hand is how do I tell VI/VIM that Drupal PHP files named "myModule.module" are php files and not simple text files, thus enabling syntax highlighting and all other goodies provided with VI? (not that I'm a VI person. I was baptised and raised as Emacs/xEmacs smiley worshipper, but lets face it - usually on remote systems which you do not own, you'll find VI ready made and not Emacs).

So, the problem is quite easily solved. The configuration file to edit, on Debian (and Gentoo), is lurking here:


Open it "in your favorite editor", search for php string and for a line in which you see several file extensions and and ending of "setf php". Edit to to have *.module extension. On my configurastion this line looks like this:

" Php, php3, php4, etc.
au BufNewFile,BufRead *.module,*.php,*.php\d setf php

Save this config file (did I mention you need to do this as root?...).
That's it.

Yes, of course there might be better ways of doing this... .

Leave a Comment

Fields with * are required.