CFEclipse Snippets
A nice introduction to Snippets can be found on CFEclipse TV. Also see SnipEx for information about setting up a snippets server.
- Import/Export Snippets
- Snippet Insertion
- User Defined Snippet Variables
- Snippet Variables *
- Useful Snippets
Import/Export Snippets
Snippets are stored as XML in the folder: {workspace location}\workspace\.metadata\.plugins\org.cfeclipse.cfml\snippets
Snippet Insertion
| [trigger text]Ctrl+J | Insert Snippet (after typing the trigger text) |
User Defined Snippet Variables
Example 1)
Upon insertion you will be prompted for the values of 'variable name' and 'default'.
<"$${variable name}" default="$${default}"/>
Example 2)
The input box for the default will be pre-filled with the value "string".
<"$${variable name}" default="$${default:string}"/>
Example 3)
Use pre-suggested enumerated values.
<"$${variable name}" default="$${default:string|boolean|date}"/>
Snippet Variables *
| $${DATE} | Ex: 11/17/2007 |
| $${MONTH} | Ex: November |
| $${TIME} | Ex: 14:25:00 PM |
| $${DATETIME} | Ex: 11/17/2007 2:42:00 PM |
| $${DAYOFWEEK} | Ex: Friday |
| $${CURRENTFILE} | Ex: application.cfm - Current file name |
| $${CURRENTFOLDER} | Ex: D:\workspace\myproject - Current folder |
| $${CURRENTPATH} | Ex: D:\workspace\myproject\application.cfm - Full path |
| $${CURRENTPRJPATH} | Ex: myproject - 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} | Ex: 01/12/2007 14:42:00 - 24 hour clock version of datetime. |
| $${YEAR} | Ex: 2007 - Current year |
| $${YEAR2DIGIT} | Ex: 07 - Current two digit year |
* these are case sensitive - if upon insertion your text does not appear - check the case
Snippet Variable Examples
This will insert the current date:
Date: $${DATE}
This would prompt you to enter a date:
Date: $${Date}
Useful Snippets
Trigger: qloop
<cfloop query="$${queryName}">
</cfloop>
Trigger: aloop
<cfloop from="1" to="#ArrayLen($${arrayName})#" index="$${indexName}">
</cfloop>
Trigger: sloop
<cfloop collection="#$${structName}#" item="$${itemName}">
</cfloop>
Trigger: lloop
<cfloop list="#$${listName}#" index="$${indexName}" delimiters=",">
</cfloop>
Trigger: lset
<cfset local.$${varName} = $${varValue} />
Trigger: vi
variables.instance.$${varName}
Trigger: try
<cftry> <cfcatch type="any"> </cfcatch> </cftry>
Trigger: for (cfscript)
for ($${initial-expression}; $${test-expression}; $${final-expression}) {
}
Trigger: afor (cfscript)
for ($${indexName}=1; i LTE arrayLen($${arrayName}); $${indexName}=$${indexName}+1) {
}
Trigger: lfor
for ($${indexName}=1; i LTE listLen($${listVar}, "$${delimiters:,}"); $${indexName}=$${indexName}+1) {
}
Trigger: sfor
for ($${keyName} IN $${structName}) {
}
Trigger: arg
<cfargument name="" type="$${Type:any|array|binary|boolean|date|guid|numeric|query|string|struct|uuid}" required="$${Required:true|false}"/>
Trigger: da
<cfdump var="#$${Variable}#" label="$${Variable}" expand="$${Expand:Yes|No" />
<cfabort showerror="dumping arguments $${Unique Value}" />
Trigger: fun
<cffunction name="$${Function Name}" output="false" access="$${Access:public|private|package|remote}" returntype="$${Return Type:any|array|binary|boolean|date|guid|numeric|query|string|struct|uuid}" hint="$${Hint}">
</cffunction>
Trigger: get
<cffunction name="get$${Variable}" access="$${Access:package|public|private|remote}" output="false" returntype="$${Return Type:any|array|binary|boolean|date|guid|numeric|query|string|struct|uuid}">
<cfreturn variables.instance.$${Variable}/>
</cffunction>
Trigger: set
<cffunction name="set$${Variable}" access="$${Access:package|public|private|remote}" output="false" returntype="void">
<cfargument name="$${Variable}" type="$${Type:any|array|binary|boolean|date|guid|numeric|query|string|struct|uuid}" required="true" />
<cfset variables.instance.$${Variable} = arguments.$${Variable} />
</cffunction>
Trigger: getset
<!--- Usage: Get$${Variable} / Set$${Variable} methods for $${Variable} value --->
<cffunction name="get$${Variable}" access="public" output="false" returntype="$${Return Type:any|array|binary|boolean|date|guid|numeric|query|string|struct|uuid}">
<cfreturn variables.instance.$${Variable} />
</cffunction>
<cffunction name="set$${Variable}" access="public" output="false" returntype="void">
<cfargument name="$${Variable}" type="$${Type:any|array|binary|boolean|date|guid|numeric|query|string|struct|uuid}" required="true" />
<cfset variables.instance.$${Variable} = arguments.$${Variable} />
</cffunction>
Trigger: qp
<cfqueryparam value="##" cfsqltype="cf_sql_$${CF SQL Type:bigint|bit|blob|char|clob|date|decimal|double|float|idstamp|integer|longvarchar|money|money4|numeric|real|refcursor|smallint|time|timestamp|tinyint|varchar}">
Trigger: fusedoc
<fusedoc fuse="$${CURRENTFILE}" language="$${Fusedoc.Language:ColdFusion|Java|PHP|ASP|ASP.net}" specification="$${Fusedoc.Specification:1.0|2.0}">
<responsibilities>$${Responsibilities}</responsibilities>
<properties>
<property name="$${Property.name}" value="$${Property.value}" comments="$${Property.comment}"/>
<history
type="$${History.type:Create|Update}"
author="$${History.author}"
comments="$${History.comment}"
date="$${DAYOFMONTH}/$${MONTH}/$${YEAR}"
role="$${History.role:Architect|Text Editor|FuseCoder|DB,Graphics}"
email="$${History.email}">
$${History.free text}
</history>
<note author="$${Note.author}" date="$${DAYOFMONTH}/$${MONTH}/$${YEAR}">$${Note.free text}</note>
</properties>
<io>
<in>
<string name=""/>
<recordset name=""/>
<number name=""/>
<boolean name=""/>
<datetime name=""/>
<array name=""/>
<structure name=""/>
<list name=""/>
<file name=""/>
<cookie name=""/>
</in>
<out>
<string name=""/>
<recordset name=""/>
<number name=""/>
<boolean name=""/>
<datetime name=""/>
<array name=""/>
<structure name=""/>
<list name=""/>
<file name=""/>
<cookie name=""/>
</out>
</io>
</fusedoc>
Trigger: dmb
<cfcontent reset="true" />
<cfdump var="#$${variable}#" label="cfdump of '$${variable}' on $${CURRENTFILE}" output="browser" />
<cfabort />
Trigger: dmc
<cfdump var="#$${variable}#" label="cfdump of '$${variable}' on $${CURRENTFILE}" output="console" />
Trigger:
Add your snippet here!!
References
- http://www.briankotek.com/blog/index.cfm/2007/7/10/Even-More-CFEclipse-Snippets
- http://www.chapter31.com/2006/10/22/cfeclipse-snippets/
- http://www.nodans.com/index.cfm/2007/7/9/Seven-snippets-for-highly-effective-developers
- http://www.dopefly.com/techblog/entry.cfm?entry=119
- http://www.trajiklyhip.com/blog/index.cfm/2006/4/18/My-CFEclipse-Snippets
- http://www.andyjarrett.co.uk/andy/blog/index.cfm/2005/3/10/Fusefoc-snippets-for-CFE-and-HS-aswell
