Editing ColdFusion with VIM

This is a quick how-to tutorial for configuring VIM for maximum productivity when Editing ColdFusion files. Not to keep you waiting, here's the configuration file:

.vimrc for ColdFusion

However, the configuration file is only one of three parts, and you'll need to go get the other two yourself. It's worth the leg-work through: when you're done you'll have syntax highlighting, keyword completion, and tag completion for .cfc and .cfm files in VIM. Sure, other editors have those features too, but they can't match VIM's raw plain-text editing power.

The Dictionary

VIM has an auto-completion feature, usually activated with Ctrl-n and Ctrl-p. It can work off any dictionary, so all we need to do is come up with a list of every ColdFusion tag name and function name we want to auto-complete. Luckily, this has already been done for us:

http://www.interaktonline.com/blogs/cristic/

The .vimrc looks for CF.dict in your home directory (~) by default, so either put CF.dict there or edit .vimrc.

The CF.dict file uses the mixedCase convention for function names and lowercase for tag names, and any keyword will be converted to that convention when you auto-complete. If this violates your local coding conventions, I recommend running a script over CF.dict to do a case conversion.

XML Editing

ColdFusion files aren't XML, of course, but they're close enough that we can benfit from some XML editing functionality. There's a good filetype plugin for editing XML:

xmledit

It has an indispensible tag completion feature. Rename the xml.vim file to cf.vim (not cfc.vim or cfm.vim) and place it in the VIM ftplugins directory.

The .vimrc provides single key mappings for the most useful xmledit functions. You might want to take a look at the xmledit documentation to see if there's anything else you want. It should be clear from the .vimrc what's being mapped, and you can easily edit those lines out if they conflict with your other mappings.

Bonus! Windows XP File Extensions

I'm sure you already know the simple way to associate a file extension with a program in XP: right-click -> open with program -> select program from list -> always use this program.

The problem with that technique is that you can only associate the default action to a program. What if you want to use different programs for Open and Edit? Say, if you wanted to use gVIM to Edit HTML files, but still use FireFox to Open them?

Here's how: Windows Explorer -> Tools menu -> Folder Options -> File Types Tab. Select an extension and an action, and the full path of the program to use. (BTW, the -R option opens gVIM in readonly mode. I'll let you put the pieces together.)

If you liked this essay, you might be interested in these: [ Web Tutorial ]

by Oran Looney - December 21st 2007

Comments (0)

Leave a Comment