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

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 Wink 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:

/usr/share/vim/vim71/filetype.vi

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.
Enjoy,
Boaz.

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

There's also

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.