-
Notifications
You must be signed in to change notification settings - Fork 0
Code 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 1. Example 1) 2. Example 2) 3. Example 3)
- Snippet Variables * 1. Snippet Variable Examples
- Useful Snippets 1. References
Snippets are stored as XML in the folder: {workspace location}\workspace.metadata.plugins\org.cfeclipse.cfml\snippets
[trigger text]Ctrl+J
Insert Snippet (after typing the trigger text)
Upon insertion you will be prompted for the values of 'variable name' and 'default'.
<"$${variable name}" default="$${default}"/>
The input box for the default will be pre-filled with the value "string".
<"$${variable name}" default="$${default:string}"/>
Use pre-suggested enumerated values.
<"$${variable name}" default="$${default:string|boolean|date}"/>
$${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
$${CURRENTFILENOEXT}
The name of the current file with no extension Ex: "index" for "index.cfm"
- these are case sensitive - if upon insertion your text does not appear - check the case
This will insert the current date:
Date: $${DATE}
This would prompt you to enter a date:
Date: $${Date}
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!!
- MXUnit : Timesavers - CFEclipse Snippets Getting started with snippets (includes download of snippets)
- Brian Kotek : Even More CFEclipse Snippets
- CFEclipse Snippets How to use Snippets in CFEclipse
- Dan Wilson : Seven snippets for highly effective developers
- DopeFly : My CFEclipse Snippets ()
- Aaron West : My CFEclipse Snippets (includes download of snippets)
- Andy Jarrett : Fusedoc Snippets for CFEclipse (and Homesite as well) (includes a download of snippets)