The eclipse/cfeclipse combinations makes for a pretty powerfull developing tool for ColdFusion programmers, even those who miss the good old days of using Homesite!
One of the cool things cfeclipse brought over from Homesite is snippets, but cfeclipse has a few extra goodies to make them better than ever
Whereas in Homesite you would assign a keyboard shortcut directly to a snippet, cfeclipse has an invoke/trigger key combination which stays the same while allowing you to use ANY key(s) as the actual trigger text for the snippet.
For example I have a cfabort snippet with a trigger text of ‘a’. Now in eclipse 3.2 the invoke/trigger combination is ctrl + j, so if I type the letter ‘a’, then press ctrl + j I get a lovely cfabort tag! Doing things this way allows me to have the same invoke key (ctrl + j) then simply remember my trigger text for each snippet. Nice
In common with Homesite is the idea of snippet variables, most handy if your snippet text requires or relies upon a user defined parameter value. An example here is cfinclude where you must specify the ‘template’ attribute.
To setup snippet variables you use the $${variable:default} format. My trigger text is ‘i’ for cfinclude, so when I invoke the snippet I get asked to enter a parameter value as follows:

My entire snippet looks like this: <cfinclude template=”$${template:.cfm}” />>
There are a number of built in snippet variables:
$${DATE}
$${MONTH}
$${TIME}
$${DATETIME}
$${DAYOFWEEK}
$${CURRENTFILE} - Current file name (just the file)
$${CURRENTFOLDER} - Current folder (The path to the containing folder)
$${CURRENTPATH} - Current path (full file name)
$${CURRENTPRJPATH} - Just the folder
$${USERNAME} - Current user
$${MONTHNUMBER} - Month as a number
$${DAYOFMONTH} - Day of month as a number
$${DAYOFWEEKNUMBER} - Day of week (the week starts on Sunday)
$${DATETIME24} - DateTime24 - a 24 hour clock version of datetime.
$${YEAR} - Current year.
$${YEAR2DIGIT} - Current two digit year.
Other than those, you’re free to name your variables as you wish.
Another SUPER cool feature is the ability to choose a default value from a range. So for my cflocation snippet I have:
<cflocation url=”$${url:.cfm}” addToken=”$${addToken:false|true}” />
Note the use of the pipe (|). There is even more than this on the cfeclipse.org site so take a peek. Some of the snippets I use are:
cfabort
cfcomment
cfdump
cfinclude
cflocation
cfoutput
cfquery
cfscript
html comment (used with xml files)
I also use tonnes of snippets for HTML, (strong, em etc). Using snippets is easy to learn and saves you a LOT of time when you’re used to invoking them with ease!
Great info, I don’t know if you are aware, but having a snippet for cfabort and cfdump are overkill. This can be accomplished by simply pressing ctrl - shift - A for abort or crtl - shift - D for dump, within cfeclipse.
leinad
November 27th, 2007
Hi leinad,
I seem to remember earlier versions of cfeclipse didn’t have this which was why I had them as custom snippets. Of course as you mentioned it’s all good now as they’re in!
Thanks for the comment
Michael Sharman
November 27th, 2007
There are tag help dialogs for creating most any coldfusion tag. Most users tend to overlook these but they work great. Its pretty much just the same as the sippets, just think of the tag itself as your trigger text and use Ctrl + t for the invoke/trigger combination.
So, to generate a loop it would go like this: type in ‘<cfloop’ then hit Ctrl + t
The dialogs are very helpful for new coders and double as time savers as well - plus, you don’t have to define anything. All of the coldfusion tags are taken care of for you right out of the box.
Snippets are more useful for complex/redundant things. If thought out and used properly, they definitely should find their way into your tool belt. So don’t forget about them.
Now if only your snippets would tie in to the editors auto-complete feature and work more like they should… like they do when in the Java perspective?
pope
January 5th, 2008
@pope - great tip, thanks for that. Learn something new everyday
Michael Sharman
January 7th, 2008