I learned to code ColdFusion with Macromedia Homesite. While it does its job very well, there came a point where I needed an IDE with more functionality and I made the leap to CFEclipse. The one growing pain I experienced, though, was losing my keyboard shortcuts. While in Homesite you can map any combination of keystrokes to any code snippet through the Options->Customize menu, the Eclipse framework limited me to snippets and keyboard shortcuts for built-in functions. The story I heard was that it was the Eclipse framework that prevented full keyboard shortcut functionality, so using a combination of Trigger Text and AutoHotkey I fixed the problem.
Trigger text: Eclipse allows you to assign text to a snippet and then launch the snippet by typing the trigger text and pressing Ctrl+J to insert it.
AutoHotkey (Windows only) is a small utility that runs in your system tray and lets you use any combination of keystrokes and mouse actions to script virtually any activity on your system. You use a config file to set up your shortcuts, and each key has a corresponding AHK code (a on the keyboard=”a”, b=”b”,^=Ctrl, +=Shift, !=Alt, etc.)
AutoHotkey has gobs of features which I won’t get into, but the key here (no pun intended) is the “Send” command, which sends keystrokes to the active window. By sending the trigger text, followed by Ctrl+J to Eclipse, AHK completely opens up your shortcut options. This is what my config looks like:
^!o::Send object{CTRLDOWN}j{CTRLUP}
^+a::Send cfargument{CTRLDOWN}j{CTRLUP}
^q::Send qp{CTRLDOWN}j{CTRLUP}
^!g::Send getset{CTRLDOWN}j{CTRLUP}
^+g::Send getarg{CTRLDOWN}j{CTRLUP}
^m::Send mailtome{CTRLDOWN}j{CTRLUP}
^+q::Send query{CTRLDOWN}j{CTRLUP}
^+v::Send var{CTRLDOWN}j{CTRLUP}
^+r::Send reqarg{CTRLDOWN}j{CTRLUP}
^!e::Send cfargevent{CTRLDOWN}j{CTRLUP}
^!q::Send fq{CTRLDOWN}j{CTRLUP}
^!s::Send ske{CTRLDOWN}j{CTRLUP}
Each line represents a keyboard shortcut and the corresponding keystrokes it sends to Eclipse. The first line sends “object”Ctrl+J (without quotes) to Eclipse. Then in Eclipse I have the following snippet

Theoretically, you could use AutoHotkey for the entire snippet, but Eclipse’s snippets do add the value of the {squiggly brackets} which allow you to set up arguments for your snippet. When I launch the snippet above, for example, Eclipse will ask me the path in a popup. There’s much more complexity to this, which I won’t get into here.
I’ve barely scratched the surface of what AutoHotkey can do. For more you can look at Lifehacker’s extensive posts about it.

5 comments
Comments feed for this article
July 17, 2009 at 12:18 am
tony
This is exactly my frustration, and exactly what I’m looking for. Any further luck or advice on this? Does it still work and are you still using it? If so, I’ll take the plunge and see if it does what I need.
Wow do I wish CFE / Eclipse allowed fully customizable shortcut keys.
July 17, 2009 at 1:41 pm
Dominic
Tony, I still happily use all of these methods without much complaint, other than the fact that adding an additional shortcut is two steps instead of one. I’m planning on moving to the new Coldfusion builder, but because it’s Eclipse based, it should all work the same.
July 20, 2009 at 2:13 pm
Moving from CFEclipse to CF Builder: First Experience « Dominic O’Connor
[...] back up, the first thing I noticed was that the snippets were missing. Snippets and shortcuts are important to me, and I really didn’t want to have to create them all over again, so I dug around in my [...]
September 21, 2009 at 10:36 pm
tony
Dominic,
I got this set up and it works well, but with some pretty serious exceptions:
- I can’t get it to do snippets that surround selected text. The hot key text will just replace any selected text, and then the snippet won’t fire.
- I can’t get it to fire if the cursor is next to a character; it will only work and fire on the hotkey text if it’s between two spaces or on its own line.
How do you just work around this problems? Or do you just live with them and only use hotkeys for other snippets?
Thanks for the heads-up on AHK in any case; it’s very cool.
-tony
October 21, 2009 at 10:41 pm
Dominic
Tony,
Very sorry for taking so long to get back to you.
For surrounding text, unless you want to use the snippet’s advanced features, you could use only AutoHotkey for this. For example, the AHK script below will surround a string of text in parenthesis if you highlight it and press control 9
^9::Send {CTRLDOWN}c{CTRLUP}({CTRLDOWN}v{CTRLUP})
Unfortunately the issue with trigger text adjacent to another character is an Eclipse weakness. I’ve run into that problem myself and haven’t come up with a good solution yet.
Dominic