CFML Editor

ColdFusion Builder provides a CFML Editor that has feature-rich code editing capabilities for CFM, CFC, HTML, JavaScript, and CSS files. The CFML Editor assists you in writing code by including features like, code completion, and streamlined code navigation. The CFML Editor lets you use different colors and fonts to display your code in the workspace.

You can customize your development environment by setting editor profiles and preferences.

Editor profiles

An editor profile lets you group and save the following editor preferences under one profile.

  • Code Assist
  • Syntax Coloring
  • Keys
  • Outline
  • Syntax Checking
  • Typing
  • Task

Editor profiles are useful when you have different editor preferences for various development needs. For example, you can select a set of preferences like Code Assist, code colorization, and keyboard shortcut preferences and save them under a single editor profile. You can apply all these settings at once by selecting the editor profile.

To create an editor profile, do the following:

  1. Specify the different editor preferences that you want to set.

  2. From the Window menu, select Preferences.

  3. In the tree-view, select ColdFusion > Profiles, and click Create New Profile.

  4. Enter a name for the profile. The current editor preference values that you set are saved under this profile.

You can also modify default settings and save the modified settings as a new profile. Additionally, you can also import or export profiles.

By default, ColdFusion Builder provides three editor profiles:

  • Default - Sets the ColdFusion Builder default editor preferences
  • Dreamweaver - Sets editor preferences similar to Dreamweaver editor preferences
  • CFEclipse - Sets editor preferences similar to CFEclipse editor preferences

To select an editor profile, click the Active Profile drop-down list in the Profiles dialog box, and select the profile.

Editor preferences

  1. From the Window menu, select Preferences.

  2. In the tree-view, select ColdFusion > Profiles > Editor.

You can specify default filenames for the CFM and CFC files that you create. To remove any trailing whitespaces in the file, select Trim Spaces Before Saving Files.

You can also specify any text or boilerplate code that must appear, by default, in every CFM and CFC file. For example, suppose you want copyright information to appear in every CFC file that you create. In this case, you can specify the copyright text in the CFC tab under New File Settings.

The editor preferences that you can set include code assist, code colorization, keyboard shortcuts, outline view, syntax checking, and typing preferences.

Optimizing ColdFusion Builder performance

The preference options that you select affect the performance of ColdFusion Builder. For faster editor performance, you can apply preset editor preferences

To apply preset editor preferences, click Optimize Editor Preferences. The following preference settings are applied:

Code Assist

The following options are deselected.

  • Automatically Display Code Assist When Typing
  • Automatically Display SQL Code Assist When Typing
  • Automatically Insert A Single Proposal
  • Automatically Insert A Closing Tag

The following options are selected.

  • Append Space After Inserting Selection
  • Automatically Insert Equal Sign (=)
  • Automatically Quote Attributes
Typing
  • Enable Auto-insertion is selected.
  • All the Auto-insert Matching Character For options are deselected.
  • Auto-close Tags is selected as Never.

Code Assist

Note:

Code Assist is also called Content Assist. These terms are used interchangeably.

Code Assist is designed to assist you with code completion. Depending on the code that you enter, hints relevant to complete the code appear. As you type the code in the CFML editor, Code Assist prompts you with a list of valid CFML tags, parameters, and attributes. These suggestions appear in a pop-up menu. If you have HTML, JavaScript, or CSS content within the CFML code, Code Assist displays code completion hints for this code as well. Double-click or press Enter, to insert the code completion hint in the CFML Editor.

Code Assist is also available for script-based syntax; for example, code hints appear for functions and components in the script syntax. When you import Ajax libraries into ColdFusion projects, Code Assist is available even for the JavaScript code.

Using Code Assist

Code hints appear whenever the framework or language (CFML, HTML, JavaScript, and CSS) provides options for you to complete the current expression. For example, if you type within a CFML tag, you are prompted with a list of all the attributes of that tag.

In a CFML page, begin entering a CFML tag by typing:<cf Relevant code hints are displayed as follows:

Code hints

  1. Navigate through the list of code hints using the Up Arrow and Down Arrow keys.

  2. Select a code hint and press Enter. The selected tag is added to the editor.

  3. As you continue to enter code, additional code hints are displayed. You can also press Ctrl+<Space> to display code hints while you enter a line of code.

The Smart Tag Assist feature of the CFML editor identifies if a tag attribute is already entered for a particular tag. If you have already entered a tag attribute, that attribute does not appear in the list of suggested attributes.

Code Assist for CFM pages

  • Displays methods and component list when you use the <cfinvoke> tag in a CFM file.
  • Displays a drop-down list of predefined attributes and values when you press <cf+Ctrl+<space>.
  • Displays a list of components (CFC) that can be loaded using createobject() or the <cfobject> tag.
  • Displays methods created in a CFC, which can be called using the component object created in a CFM. Also displays a list of methods of all extended CFC files.
  • Displays a drop-down list of all built-in and user-defined functions.
  • Provides a list of variables, like, struct, array, query. These variables are declared in a page. The variables also appear as Code Assist for attribute values.
  • Displays all the queries created using <cfquery> or queryNew(). To view the recordset, type <cfoutput query="">, and press Enter. or use queryname. (that is, query name followed by dot).
  • Includes the functions, variables, tags, and queries from another CFM page once it is included in the current CFM page using the {{<cfinclude> }}tag.
  • Allows you to browse and select a file as the input value for an attribute of CFM tags. CFM tags that require a file as the input value include <cfinclude>, <cfimage>, <cfdirectory>, <cfpdf>, <cffile>, <cfzip>, <cfspreadsheet>, and <cfcollection>.

Code Assist for CFC pages

  • Displays a list of components (CFC) that can be loaded using createobject().
  • Displays a list of components (CFC) that can be loaded using the <cfobject> tag.
  • Displays methods created in a CFC, which can be called using the component object created in a CFM.Examples:
    • <cfset obj1 = createobject("component", "c1")><cfset x = obj1.method1()>
    • <cfset obj2 = createobject("component", "c2").init()>
    • <cfset obj3 = new "c3"().method3()>
    • <cfinvoke component="c4" method="method4">
  • Displays a list of methods of all extended CFC files. The "extends" and "implements" keyword/attribute lists the available components and interfaces.
  • Displays a list of components that can be extended in the current CFC file.

Note:

Code Assist is not supported for comments that are added to component properties. For example, Code Assist is not supported for a comment that you add to the numeric accountID property as follows:/** @ – code assist is not supported here --*/

  • Displays a list of interfaces that can be used in a CFC with the implement keyword.
  • Allows you to browse and select a file as the input value for an attribute of CFM tags or functions like <cfif fileexists()>. CFM tags that require a file as the input value include <cfinclude>, <cfimage>, <cfdirectory>, <cfpdf>, <cffile>, <cfzip>, <cfspreadsheet>, and <cfcollection>.

Code Assist for scoped variables using variable mapping

Many ColdFusion frameworks create CFCs during application startup and store these CFCs as scope variables. To provide Code Assist for such CFCs, ColdFusion Builder must determine the content and data type (fully qualified name of the CFC).

To enable Code Assist for CFCs that are stored in scoped variables, define a project-level mapping for the variable name and its corresponding CFC type. ColdFusion Builder uses this mapping information and displays a list of CFC methods for the mapped variable, without creating an object of that data type. For example, you can map mycfc1 to com.adobe.mycfcs.cfc1. When you type mycfc1 and press Ctrl+<space>, all the methods available for com.adobe.mycfcs.cfc1 appear.

To configure a variable mapping, in the Properties dialog box, Specify the variable to map as mycfc1 and the mapped to value as com.adobe.mycfcs.cfc1. For more information, see Configure variable mappings.

Code Assist for ColdFusion ORM

Object Relational Mapping (ORM) is a programming technique that lets you define a mapping strategy using object models. You can use Object Relational Mapping to store and retrieve data from a relational database.

ColdFusion Builder provides Code Assist for the following ColdFusion ORM settings:

  • Entity names in entityLoad, entityNew, and entityFindByPK functions.
  • Methods and properties returned by entityLoad, entityNew, and entityFindByPK functions.
  • Code hyperlinks for entity names and methods.
  • Data sources in application.cfc. For example, <cfset this.datasource = >.
  • Table attribute of the cfcomponent tag.

For more information about using ColdFusion ORM, see ColdFusion ORM in the ColdFusion Developer Guide.

Code Assist for Application.cfm and Application.cfc files

Code Assist is available for Application.cfm and Application.cfc files.

Application.cfm is considered an included file and Code Assist is available for all variables and functions within the file.

For Application.cfc, Code Assist is available only for scoped variables that are declared in onApplicationStart.

Set CFML Editor Code Assist preferences

  1. From the Window menu, select Preferences.

  2. In the tree-view, select ColdFusion > Profiles > Editor > Code Assist.

    • You can select the Code Assist Dictionary version to assist with code completion. ColdFusion 9, ColdFusion 8, and ColdFusion MX7 dictionary versions are supported.
    • Select the Automatically Display Code Assist When Typing check box to automatically display Code Assist when typing.

Note:

When editing large-sized files, you can deselect the Automatically Display Code Assist When Typing check box to improve performance of the editor. You can, however, display code hints while you enter a line of code by pressing Ctrl+<Space> or any other keyboard shortcut that is set.

  • You can choose to automatically quote attributes and select closing tags.

Code hyperlinks for CFCs and UDFs

Component names and UDFs are hyperlinked on Ctrl+hover. If you click the hyperlink, the corresponding code is opened in ColdFusion Builder. Code hyperlinks are available for:

  • UDFs: local, included, and cfc.udfName
  • Template in <cfinclude template=””>
  • CFCs in createobject(), <cfobject>, <cfinvoke>, new keyword, and extends attribute.

CFC name resolution using server mapping

Use ColdFusion Administrator to define server mapping for CFCs. The server mappings allow you to view these CFCs as part of Code Assist when you use the extend or implement keywords.

ColdFusion server mappings let cfobject and cfinvoke tags, or functions like createObject or new, access pages and find ColdFusion components outside the document root.

If you specify a path in these tags that starts with the mapping's logical path, ColdFusion looks for the CFC using the mapping's directory path. You can define server mapping for the CFCs using the ColdFusion Administrator. After mapping, you can view the CFCs in Code Assist when you use the extend or implement keywords, and component or method attributes. The CFCs suggested in Code Assist are resolved with their fully qualified names.

Once mappings are created for the CFC name resolution from the server, the server settings are cached and available even when the server is not running. The server settings are collected when the server is started or refreshed from ColdFusion Builder.

Specify server settings

  1. From the Windows menu, select Preferences.

  2. In the tree view structure, select ColdFusion > Server Settings.

  3. Select the Build Server Settings check box and the Required check box to indicate the action for collecting server settings. For example, to collect server settings each time you start ColdFusion Builder, select the ColdFusion Builder Started check box.

CFML Dictionaries

ColdFusion Builder provides in-built dictionaries that assist you with CFML code completion. The CFML dictionary is an XML file that contains information about each tag and function contained in the library. For example, the CF9 dictionary file (cf9.xml) contains information about all the available CF9 tags and functions.

ColdFusion Builder provides dictionary support for ColdFusion 11, ColdFusion 10, ColdFusion 9, ColdFusion 8, and ColdFusion MX7 versions.

To select a dictionary version, do the following:

  1. From the Window menu, select Preferences.

  2. In the tree-view, select ColdFusion > Profiles > Editor > Code Assist.

  3. Select the Code Assist Dictionary version drop-down list and select a dictionary version to assist with code completion.

  4. Click Reload Dictionaries to reload all the dictionaries, including custom dictionaries.

Create custom CFML dictionaries

You can create a custom CFML dictionary (XML file) and make it available to use for Code Assist and Tag Editor within ColdFusion Builder.

  1. Within the ColdFusion Builder installation, navigate to the following location:\plugins\com.adobe.ide.coldfusion.dictionary_XXX\dictionary

  2. Create a folder called "Custom" within the Dictionary directory.

  3. Create an XML file to describe the custom tags and functions. For example, in the XML file, you describe each tag within <tag></tag> elements, and enclose all the tag elements within <dictionary></dictionary>elements as follows:

<dictionary>
<tags>
!--
cfabort
showError = "error_message"
-->
<tag endtagrequired="false" name="cfabort" single="true"
xmlstyle="false">
<parameter name="showerror" required="false" type="String">
</parameter>
</tag>
</tags>
</dictionary>

See the cf9.xml or cf8.xml files as reference to create the custom CFML dictionary.

Auto-insertion of required attributes

In the Code Assist (Window > Preferences > ColdFusion > Profiles > Editor > Code Assist), select Auto Insert Required Tag Attributes to insert the required attributes of a tag.

Note:

This is the default setting.

For example, if you select cfpdf "action=write", all the required attributes destination, source, and name are automatically inserted.

If the preference is not selected, the attributes are not inserted but only proposed.

Separate list of required and optional attributes

Code Assist prompts you with a list of tag attributes as follows:

  • Shows required tag attributes at the top of the proposal list with check marks to indicate that the attributes are mandatory.
  • A line separates the mandatory and optional attributes.

Proposals for createObject

Code Assist proposes all objects (and the corresponding arguments) supported by the function createObject.

Cyclic Code Assist proposals

In the Code Assist (Window > Preferences > ColdFusion > Profiles > Editor > Code Assist), select Cycling Code Assist Proposals for cyclical code assistance.

Note:

This is the default setting.

Consider the scenario where when you press Ctrl+<Space>:

  • Variables, scopes, and UDFs are listed
  • On this list, if you further press Ctrl+<Space>, all built-in functions are proposed
  • On this list, if you further press Ctrl+<Space>, all proposals are listed.
  • The cyclic proposals continue on subsequent use of Ctrl+<Space>.

Note:

Cyclic Code Assist does not appear if you manually specify a part of the text for which you want prompt.

Filter proposals containing text

In the Code Assist (Window > Preferences > ColdFusion > Profiles > Editor > Code Assist), select Filter Proposals Containing Text to filter proposals based on the text you specify.

Note:

This is the default setting.

All proposals that contain the filter text you specified are listed with selection set to the proposal that starts with the specified text.

Datatype-aware Code Assist

Shows Code Assist proposals based on expected data types.

For example, when you load Code Assist within the function Abs, it shows functions and variables of type numeric, Any, or complex data types such as array, struct, or component.

Auto-insertion of function arguments

When you insert a function, all required arguments are automatically inserted. By default, the first argument is selected.

Function context assist

  • ColdFusion Builder displays function context assist whenever you load Code Assist inside function parameters.

Note:

In ColdFusion Builder (the previous release), function context assist appears only after you insert functions from the Code Assist proposals.

  • Parameter that you currently edit is highlighted in bold.

  • Optional parameters are displayed inside [].

Smart Code Assist for connection attributes

Smart Code Assist displays connection variables created for tags such as cfexchangeconnection and cfftp.

Usage-based Code Assist for cfloop

Based on the type of loop, the required attribute is auto-inserted. For example, if you loop over an array, the attribute index is auto-inserted.

Select tag blocks of your choice

Use the shortcut Ctrl+Alt+B (Windows) or Command+Option+B (Mac) to select tag blocks. The enclosing tag block from the caret position is selected.

Retain the selection and repeat the shortcut for cumulative selection of code.

For example, in the following snippet, when you press Ctrl+Alt+B/Command+Option+B, the cfform tag block is selected. If you retain the selection and then press Ctrl+Alt+B/Command+Option+B, code selection is extended to the next level of enclosure. That is, the entire code block is selected.

<cffunction name="test">
<cfform name="form1">
<!--- caret position --->
</cfform>

Jump to matching tag

Use the shortcut Ctrl+Alt+M (Windows) or Command+Option+M (Mac) to move the caret position from beginning to end or end to beginning of a tag block.

Note:

The caret position can be anywhere within the start or end tag (and not exactly on the tag name).

Quick Fix

Quick Fix recognizes the usage of methods, classes, and CFC/CFM files in the code and helps you generate them.

For example, if you type a user-defined function {{test() }}that is not defined in the page or any included page, Quick Fix helps you generate the function. The function call is inserted in the file.

When you open/edit a file, ColdFusion Builder automatically identifies the function calls, CFCs, and CFMs that are not defined. A bulb icon appears in the left margin of the editor which, if clicked, prompts you to perform the appropriate quick fix.

Note:

The shortcut CTRL+1 also yields the same result.

You can turn off the Quick Fix by unchecking Enable Quick Fix (Window > Preferences > ColdFusion > Profiles > Editor > Syntax Checking).

Quick Fix helps you in the following scenarios:

  • Call to local UDF in any language construct, for example cfset or cfscript assignment, function arguments, or any other expression. If you specify any arguments in the UDF, then Quick Fix also creates the arguments. Depending on where the function is called, ColdFusion Builder generates the code.Both tag and script-style syntax are supported, depending on the context. That is, Quick Fix generates a method in script-style if it is called in script-based syntax.
  • Method call on a CFC, for example cfc1.function1(). If function1 is not defined in CFC1, then Quick Fix creates it.
  • Create CFC from createObject, new, cfobject, and cfinvoke. ColdFusion Builder provides options to create CFC with respect to wwwroot (if the server is associated with the project), project, or in a folder selected by the user.
  • Create CFM page from cfinclude and cfmodule
  • Create CFCs and CFMs from extends and implement attributes.

Example

<cfset o1 = new component1()>
<cfset st = structNew()>
<cfset result = getResults("abc", 10, st)>
<cfinclude template="test3.cfm" >
<cfscript >
o2 = new component2();
//Assume that component2 exists
o2.someFunction();
</cfscript>
Line of code Issue Prompt
<cfset o1 = new component1()> Component is not created Create CFC
<cfset result = getResults("abc", 10, st)> Function getResults does not exist Create the function getResults
<cfinclude template="test3.cfm" > test3.cfm does not exist Create test3.cfm
o2 = new component2(); Component does not exist Create someFunction in component2.

Code Formatter

Formatting your code

Note:

To format a section of the code, select it before step 2.

Customizing the preferences

Code Formatter has an off-the-shelf set of preferences defined in a profile. To customize the preferences, create a profile or modify the default profile after giving a new name.

  1. In ColdFusion Builder, select Window > Preferences.

  2. In the tree view, select ColdFusion > Profiles > Editor > Formatter.

  3. Click Add to add a new profile or Edit to edit an existing profile after selecting the profile in the Active Profile.

    Note:

    You cannot edit the default profile.

  4. In the CFML Formatting Profile, add or modify the profile by setting the rules specified in the following table. The code formatting preferences are based on the rules. Each tab in the dialog box represents a rule.

    Rule Options to
    General •  Specify if you want to maintain the case currently used for tags and attributes, or change it to upper or lowercase.
    •  Append /> at the end of the tag, for example, modify <cfargument …. > as <cfargument …. />. Specify the tag to which you want to append /> and then click Add.
    •  Place the closing tag for cfoutput (</cfoutput>) on a new line only if the content spans to multiple lines.
    Indentation •  Specify the indentation details and the name of the tags for which you do not want to apply indentation.
    White space •  Add white space based on your selections.
    •  Add blank lines based on your selections.
    •  Specify the number of blank lines that you want to retain.
    Wrapping

    •  Specify the number of attributes in a line within a tag and set the column width.
    •  Specify various constructs for wrapping.

    Braces

    •  Specify if the curly braces are placed in the same or new line for component and function declarations and switch, if, else, and try blocks.

Sharing the preferences

You can share the formatting preferences in XML format.

Use the appropriate buttons in the Formatter section of the Preferences dialog box (Window > Preferences > ColdFusion > Profiles > Editor > Formatter) to export your preferences or import preferences shared by somebody.

Auto-formatting

ColdFusion Builder automatically indents lines of code and adjusts the ending tag, to improve readability.

Auto-formatting works in the following scenarios:

When you type code

  • Indents when you press Enter with the cursor placed after
  • > of the start tag
  • Opening curly brace ({)
  • > for closing tag.
  • the closing tag if it is auto-completed while typing </.
  • When closing, curly brace (}) is placed in alignment with the opening curly brace ({).

When you use Code Assist

  • If you auto-insert closing tag, while typing forward slash (/), it is placed at the correct location with respect to the start tag.
  • If you auto-insert closing tag, it is aligned to the start tag.

Code colorization

ColdFusion Builder can highlight the syntax for CFML tag names, attributes, attribute values, keywords, comments, and various other elements in different colors. Code colorization is also supported in script-style coding. You can customize the color preferences and override the default Eclipse editor color preferences.

Set CFML Editor color preferences

  1. From the Window menu, select Preferences.

  2. In the tree-view, select ColdFusion > Profiles > Editor > Syntax Coloring.

    • You can import and export your color preferences as a COL file.

Set SQL Editor color preferences

  1. From the Window menu, select Preferences.

  2. n the tree-view, select ColdFusion > Profiles > Editor > Colors. Under Tokens, scroll down to SQL, and select color preferences for comments, keywords, and text.

SQL Editor

The CFML editor has an integrated SQL editor that lets you edit, write, and execute SQL statements.

To use the SQL editor, you must have a server configured and running in ColdFusion Builder. The SQL editor does not support offline databases.

The SQL Editor supports Code Assist and code colorization for the following types of SQL statements:

  • Select
  • Insert
  • Update
  • Delete

Note:

For SQL statements within the cfquery tag, Code Assist is available in the CFML Editor itself. You need not open the SQL Editor for code completion hints.

Using SQL Editor

  1. Do one of the following:

    • Right-click in the CFML editor, and select SQL Editor.
    • Use the keyboard shortcut Ctrl+Alt+S (Windows) or Command_Alt+S (Mac OS).
  2. In the SQL Editor, select a server from the Server drop-down list and a database from the Datasources drop-down list.

  3. Enter the SQL statement and do the following:

    • Click Execute Query to display the results of the SQL statement in the Query Result tab. You can execute only SELECT statements in the SQL Editor.
    • Click OK to insert the SQL statement in the CFML editor at the current caret position. caret is the marker in the CFML editor that indicates where the next character appears.
  4. You can also copy SQL code blocks from the SQL Editor directly into the CFML editor by selecting the code block and pressing Shift+Enter.

  5. To edit a SQL code block in the CFML editor, select the code block, right-click, and select SQL Editor. The selected code block appears in the SQL Editor.

For more information about basic SQL syntax and writing SQL statements, see Using SQLin the ColdFusion Developer Guide.

SQL Code Assist

SQL Code Assist is available only for database table names and field names in the SQL statement.

By default, SQL Code Assist is turned on in ColdFusion Builder, and code hints for SQL statements are automatically displayed in the CFML Editor. To turn off the automatic display of SQL Code Assist, do the following:

  1. From the Window menu, select Preferences.

  2. In the tree-view, select ColdFusion > Profiles > Editor > Code Assist.

  3. Deselect Automatically Display SQL Code Assist When Typing.

Even with the automatic display of SQL Code Assist turned off, you can still get code hints within your SQL statements as follows:

  1. Begin entering the SQL statement in the SQL editor and press Ctrl+<Space> to display the database table names or field names.

  2. Navigate through the list of table names or field names using the Up Arrow and Down Arrow keys.

  3. Select a table name or field name and press Enter. The selected table or field is added to the SQL statement.

ColdFusion Builder provides Code Assist for the query attribute of the <cfoutput> tag. For example, when you type, <cfoutput query="">, and press Ctrl+<Space> with the caret position between the double quotes "". A list of queries created in that file or included files appears.

Code Assist is also provided for query names that are used in expressions.

For example, if you create a query like:

<cfquery datasource="dsn1"name="q1">
Select id, firstName, lastName from employee
</cfquery>

When you type the expression <cfset name = q1.> and press Ctrl+<Space>, ColdFusion Builder displays the columns selected in that SQL query.

SQL Code colorization

In the CFML editor, SQL code colorization is supported only within the cfquery tag. You can colorize SQL keywords, comments, and text within the cfquery tag. Colorization is supported only for the following types of SQL comments:

  • /* */

To set SQL code colorization preferences, see Set SQL Editor color preferences.

Code folding and unfolding

The CFML editor provides many shortcuts for navigating through your code. Shortcuts include folding and unfolding code blocks, opening the source of code definitions, and browsing and opening types. You can collapse and expand multiline code blocks to navigate, view, and manage complex code documents. In ColdFusion Builder, collapsing and expanding multiline code statements is called code folding and unfolding. You can use this feature in a CFM, CFC, or HTML file.

You can hide and display code blocks of your preference. The code folding that you define is saved and therefore is available for future sessions.

  • In the CFML Editor, click the fold icon (-) or the unfold icon (+) in the left margin of the editor.

Folding a code block hides all but the first line of code.

Move the pointer over the unfold icon  to show the folded code in a tool tip.

Unfold a code block to make the code visible

  • By default, all the lines of code are expanded. To fold or collapse all the lines of code except the first line, right-click in the left margin of the editor. Then select Folding > Collapse All.

Add code folding

  1. Select the block of code you want to hide.

  2. Do either of the following:

    • Press Ctrl+Alt+F (Windows) or Command+Option+F (Mac)
    • Right-click and then select Source > Toggle Folding at Selection

Remove code folding

To remove code folding for a block of code,

  1. Place the cursor on the first line of code and then repeat the steps used to fold the code.

Note:

You cannot have multiple code folding starting with the same line of code.

Syntax checking and highlighting

When you select a tag or code bracket in a CFM file, the matching pair of the tag or bracket is automatically highlighted.

If you type code that is not recognized as valid CFML code, you are notified in the following ways:

  • A cross-mark appears next to the line of code.
    Hovering your pointer on the cross-mark gives more details about the error.
  • The Problems view lists the errors

    Each message contains a brief description of the error, the file and folder in which the error occurs, and its line number in the file. When you double-click the error, the file is opened in the editor and the line of code is highlighted.

Note:

Syntax errors are displayed only for open CFM files and are not displayed after you close a CFM file.

Depending on the nature and severity of the errors, your application sometimes does not run properly until the errors are corrected.

Syntax checking preferences

  1. From the Window menu, select Preferences.

  2. In the tree-view, select ColdFusion > Profiles > Editor > Syntax Checking.

  3. Syntax checking is turned on by default. To turn off syntax checking, deselect Enable Syntax Checking.

  4. To display syntax errors only when opening or saving a file, select Display Syntax Errors Only on File Save. While editing the file, all errors in the file are removed from the Problems view.

Code navigation

Use the shortcuts Ctrl + Shift + Up arrow key and Ctrl + Shift + Down arrow key (Windows) or Command + Shift + Up arrow key and Command + Shift + Down arrow key (Mac) to easily navigate inside your code.

Code navigation works for both tag and script-based syntax.

The following sections explain how code navigation functions in various scenarios:

In CFM files

Caret position changes from a user-defined function to the next or previous one.For example, in the following snippet, if the caret position is on or within func1, if you press Ctrl + Shift + Down arrow key, then the caret position moves to func2 and selects the function name. From anywhere on or within funct2, }}if you press Ctrl + Shift + Up arrow key, then the caret position changes to {{func1 function and selects the function name.

<cffunction name="func1">

</cffunction>

<cffunction name="func2">

</cffunction>

In CFC files

Caret position changes

  • From a user-defined function to the next or previous one.
  • To the top-level members of the CFC, for example to cfproperty directly inside the CFC. For example, in the following snippet, if you navigate from line number 1 (<cfcomponent>) downward, then caret position first changes to line 2 (<cfproperty name="prop1">), and further to line 4 (<cffunction name="func1">), and line 6 (<cffunction name="func2">). Moving upward, the caret position changes, taking the same path in the reverse order.When the caret position changes to cfproperty, the name is selected.

<cfcomponent>

<cfproperty name="prop1">

<cfset this.var1 = 100>

<cffunction name="func1">

</cffunction>

<cffunction name="func2">

</cffunction>

</cfcomponent>

In flow-control statements

For flow-control statements provided in CFScript (for example, in statements if-else, switch-case, and try-catch), in both CFC page and CFM page, caret position changes to the next or previous code blocks if the caret position is within any of these statements.For instance, if you press the same key combination withincfif tag, then caret position changes to the next cfelseif or cfelse statement.In the following example, if you navigate down from

  • Line 1 (<cffunction name="func1">), caret position changes directly to line 10 (<cffunction name="func2">).
  • Within cfif in line 2 (<cfif a eq 10>), caret position changes to line 4 (<cfelseif a gt 10>) andcfelseif is selected, provided the caret position is on line 2.
  • Line 4 (<cfelseif a gt 10>), caret position changes to line 6 (<cfelse>)and cfelse is selected
  • Line 6 (<cfelse), caret position changes to line 8 (</cfif>).
  • Line 8 (</cfif>), caret position changes to line 10(<cffunction name="func2">) and func2 is selected.

If you do a reverse navigation (Ctrl + Shift + Up arrow key),

  • From line 6 (<cfelse), caret position changes to line 4 (<cfelseif a gt 10>) and {{cfelseif }}is selected.
  • From line 10, caret position changes to line 1{{ (<cffunction name="func1">}}).
<cffunction name="func1">

<cfif a eq 10>

<cfset b = 10>

<cfelseif a gt 10>

<cfset b = 20>

<cfelse>

<cfset b = 30>

</cfif>

</cffunction>

<cffunction name="func2">

</cffunction>

Smart tab navigation

You can quickly navigate to the next (use Ctrl + ] on Windows or Command + ] on Mac) and previous (use Ctrl + [ on Windows or Command + [ on Mac) function argument or tag attribute.

If caret position is at function call or tag name, for downward navigation, the position changes to the first parameter/attribute value.

For nested function calls, caret position changes to the next or previous parameter when you reach the end/beginning of parameters.

Smart tab navigation is applicable to cffunction arguments also in the case of function definition, for example

<cfscript>function abc(int a, int b) access=”package” output=”false”</cfscript>

In this case, when the caret position is on abc or function, it navigates to int a, int b , package, andfalse.

Smart tab navigation applies to both tag-based and script-based syntax.

Code refactoring

Code refactoring is the process of improving the source code of a program without changing the overall result. Generally, code refactoring improves code readability and maintainability.

ColdFusion Builder supports various refactoring techniques like renaming, searching, and previewing of CFCs, CFMs, and UDFs at the project and workspace levels.

Refactor CFC or CFM filenames

When you rename a CFC or CFM, you can refactor all valid instances of the CFM or CFC, including all references to the CFM or CFC.

  1. Right-click the file in the Navigator pane.

  2. Select Refactor > Rename.

  3. Enter the new name and preview the changes. When you preview the changes, you can review the selected instances and deselect any instance that you do not want to rename.

  4. To rename CFCs or CFMs across all projects in the workspace, select Update All Projects In The Workspaces.

    Note:

    You cannot rename a CFC or CFM in HTTP or Web server URLs unless the server is registered and running.

Refactor UDFs in CFC or CFM filesTo undo refactoring, use the keyboard shortcut Ctrl+Z (Windows) or Command+Z (Mac).

  1. Open the CFM or CFC file in the editor.

  2. Point to the function name, right-click, and select Refactor > Rename

  3. Specify the UDF name and click OK.

    Note:

    Currently, function renaming is supported only through the main function declaration and not from function calls.

Notes and considerations

  • The location of a CFM or CFC file cannot be changed although the inherent Eclipse editor provides the capability to move files using the Move option.
  • The CFML Editor does not support renaming a folder although Eclipse provides this option.

Refactoring methods

You can refactor methods created for application variables by creating variable mappings.

For example, consider a scenario where an application variable is defined for a CFC object as follows:

<cfset Application.appVar = createObject("component","abc.AppCFM.a")>

Say, you have a CFC function, Method(), that you call as follows:

<cfset Application.appVar.Method()>

Reference search

To refactor the Method() function, create a variable mapping for the application variableApplication.appVar as follows:

  1. In the Navigator view, right-click the project and select Properties.

  2. In the Properties dialog box, select ColdFusion Variable Mappings.

  3. Click New, enter the following details in the Add Mappings dialog box:

    • Variable Name: Application.appVar
    • Mapped To: abc.AppCFM.a

You can search for a CFC, CFM, or UDF in a project or workspace.

  1. Right-click the project in the Navigator pane.

  2. Click References and select Project or Workspace. The results are displayed in the Search window in ColdFusion Builder.

Other than searching for references at the project or workspace level, you can search for references while working in the CFML code editor. Right-click in the CFML editor and select References > File to search for file references. You can also search for references at the project and workspace level from within the CFML editor.

Tag Editor

The Tag Editor assists you in adding tags and their attributes, even if you are not familiar with CFML. To use the Tag Editor in ColdFusion Builder, do the following:

  1. Click the CFML tab in the Source area, if it is not already open.

  2. Click the Tag Editor icon from the CFML toolbar. You can also open the Tag Editor by pressing the Ctrl+Shift+T.

  3. If you do not know the tag, then search for the tag using the Tag Editor dialog box.

  4. Specify the values for the tag attributes. The Tag Editor also displays values specific to an action attribute.

  5. Click OK to add the tag to a CFML page.

Note:

 The Tag Editor is context sensitive, so you can edit a tag by moving the cursor to the tag and pressing Ctrl+Shift+T. The Tag Editor for that tag is displayed, and you can specify or change the tag attributes.

Typing preferences

When typing CFML tags, you can customize your typing preferences. You can specify preferences like the following:

  • Auto-insert closing tags and matching characters (like, quotes and curly brackets)
  • Auto-indent child tags on pressing Enter and replace whitespace with indentation character
  • Auto-change the matching tag when you modify a pair tag
  • Auto-suggest single quote and double quote when you quote attributes

Set CFML Editor typing preferences

Auto-insertion is enabled, by default. You can auto-insert matching characters for single and double quotes, brackets, and the ’#’ sign.

To turn off auto-insertion, do the following:

  1. From the Window menu, select Preferences.

  2. In the tree-view, select ColdFusion > Profiles > Editor > Typing.

  3. Deselect Enable Auto-insertion.

CFML Editor keyboard shortcuts

ColdFusion Builder lets you:

  • Use a Quick Assist that displays a catalog of shortcuts related to wizards, tags, and custom shortcuts
  • Create custom keyboard shortcuts
  • Modify and remove shortcuts
  • Search shortcuts for specific action based on filter text
  • Export shortcuts in CSV format and import
  • Restore defaults shortcut settings

Default shortcuts

Default shortcuts are the factory defaults listed in the Preferences dialog box (Window > Preferences > ColdFusion > Profiles > Keys).

You can import and export default shortcuts, but cannot change their name or description.

You can temporarily remove default shortcuts or modify them. When you click Restore Defaults in the Keys section of the Preferences dialog box, you lose all shortcuts you added, and any modifications. Also, the default shortcuts you deleted are restored.

Shortcut conventions

For ease of organizing and use, it would be a best practice to follow a standard format for your keyboard shortcuts. For the default shortcuts, ColdFusion Builder follows the following formats:

  • For tags, Ctrl + T (Windows) or Command+T (Mac). For example, Ctrl + T, A (Windows) or Command+T, A (Mac) for cfabort.

Note:

The comma between Ctrl + T/Command+T and A indicates a sequence. That is, you have to first press Ctrl+T/Command+T, release the keys, and then press A for the shortcut to take effect.

  • For wizard-related shortcuts, Ctrl+Alt+W (Windows) or Command+Option+W (Mac).

Similarly, follow a convention which can make your shortcuts intuitive.

Also, to avoid shortcut conflicts, ensure that you define unique key bindings.

 

Create custom keyboard shortcuts

  1. In ColdFusion Builder, select Window > Preferences > ColdFusion > Profiles > Keys.

  2. Click Add.

  3. Specify a unique name and description for the shortcut.

  4. In the Key Binding, specify the shortcut.Conflicts are listed if you do not specify a unique key binding.

  5. In the Inserting Text box, specify the text that must be inserted in the editor when you use the shortcut. The section Define caret position explains how to use macros to specify the caret position in the inserted text.

  6. Click Save and then OK to close the preferences.

Define caret position

You can use macros to define caret position in the text (for which you create the shortcut) when it appears in the editor.

In the Keys section of Preferences dialog box, when you insert the text, specify the $${cp} macro in the position where you want the cursor to appear.

For example, if you specify

if($${cp}){ <cfoutput>#A#</cfoutput>}

with the binding Alt + T, when you use the shortcut, the block of text is inserted in the editor with the cursor between the parentheses that follows{{ if}}.

Quick Assist

Quick Assist shows up the catalog of shortcuts for quick reference:

  • Press Ctrl+T (Windows) or Command+T (Mac) to launch Quick Assist for tag-related shortcuts and custom keyboard shortcuts.
  • Press Ctrl+Alt+T (Windows) or Command+Option+T (Mac) to launch Quick Assist for wizards-related shortcuts.
  • Press the part of the custom keyboard shortcut that precedes comma. For example, assume that you have set the bindings Alt+T, A and Alt+T, B. Then, if you press Alt+T, Quick Assist lists both the shortcuts.

Additional resources

ColdFusion Builder Search

ColdFusion Builder Search provides specialized find and replace functionality to search text or tag. Apart from searching the current document, the scope of search can be any open document, selected resources in the Navigator pane, project, working set, workspace, local directory, FTP location, or RDS location. The feature also supports regular expressions and multi-line search.

To save time, you can run remote search in the background and continue with other tasks. The Search View provides the results with details of matches in each file you search.

ColdFusion Builder search applies only to the following file types: CFC, CFM, HTML, XML, CSS, and JS.

Performing search

  1. Run the ColdFusion Search dialog box using either of the following options:

    • In an open document, use the shortcut Ctrl+F (Win) or Command+F (Mac).
    • From the Window menu, select Search > ColdFusion Search.

    Note:

    If you use this shortcut in any other context, for example, in a TXT file, the Eclipse Find/Replace dialog box appears instead. However, you can purposely open ColdFusion Search dialog box using the option Search > ColdFusion Search.

  2. In the ColdFusion Search dialog box, specify the scope of your search. Depending on the scope, the search options vary.For example, the option Recurse subfolders (used to include subfolders in the search) applies only when your scope is FTP location, RDS location, or local directory.

  3. (If the file is not open) To narrow down the search, specify the filename extension.

  4. Do either of the following:

    • Specify the text to search and if necessary, the text to replace.
    • Specify the tag to search, and then
    1. Choose a tag and specify the conditions for search. For example, search for cfimage tag with attribute source containing cf.jpg.
    2. Click Add to add the condition to the list.
    3. Select an action, that you want to perform, when the tag is found (such as removing or replacing the tag). If applicable, specify any additional information necessary to perform the action. For example, setting a new attribute for cfimagethickness.

    Note:

    Actions apply only if you use Replace or Replace All.

  5. Use the following options to expand or limit the search:

    • Match Case: Limits the search to text that exactly matches the case of the text you want to find.
    • Match Whole Word: Limits the search to text that matches one or more complete words.
    • Search Backwards
    • Search Incrementally: Lets you progressively search for and filter through text. When you specify search criteria, highlights the first occurrence of the typed characters.
    • Use Regular Expressions: Causes certain characters and short strings (such as ?, *, \w, and \b) in your search string to be interpreted as regular expression operators. For example, a search for the b\w*\b dog matches both the{{ black dog}} and the barking dog.
    • Ignore White spaceTreats all whitespace as a single space for the purposes of matching. For example, with this option selected, this text would match this text and this text but notthistext. This option is not available when the Use Regular Expressions option is selected; you must explicitly write your regular expression to ignore whitespace.

    Note:

    The tags  and  are not treated as whitespace.

    • Wrap Search: Performs end-to-end search from the current cursor position.

    Note:

    Depending on the search scope, some options are disabled.

  1. To search (and not perform any action), click Find or Find All.
  • Find jumps to and selects the next occurrence of the search text (only) in the current document.If tag is selected, the tag block is highlighted.
  • Find All lists the files and the number of matches in each file in the Search View.
  1. To replace found text/perform action on tag, click Replace or Replace All.

Search options are saved when you close ColdFusion Builder.

ColdFusion Builder Search View

ColdFusion Builder Search View displays the search results of current search and maintains the history of previous searches.

ColdFusion Builder Search View

  • Shows results only if the user clicks Find All.
  • Displays results with folder hierarchy; click the file to see the search instances.
  • Displays the line numbers for code if search criteria matches. Double-click the line to open the file and see the specific occurrence.
  • Indicates if no matches are found.

Additional resources

  • ColdFusion Builder Search\Replace ColdFusion Builder engineering team member Sagar Ganatra explains the features of ColdFusion Builder search.
  • Tag search ColdFusion Builder engineering team member Sagar Ganatra explains how to find tags that match your search criteria.

Add tasks to Task View

If you define tasks as CFML comments, the Task View (Window > Show View > Tasks) displays them based on the priority you set. The tasks are listed according to the default TODO and FIXME tags or the custom task tag prefix.

Add tasks

  1. Open the CFM or CFC file in the editor.

  2. Add the task in the format as shown in the following examples:

<!--- TODO: Fix the bug 268451 --->

or in cfscript

//TODO: Fix the bug 268451

and

/*TODO: Fix the bug 268451*/

View tasks

The Task View (Window > Show view > Tasks) displays the first line of the CFML task comments.The priority column indicates if the task is of high, normal, or low priority. High priority tasks are indicated using red color.Tasks in all open CFM files are displayed. Since the tasks are saved, they are displayed in the later sessions, when you open the files.

Create a custom Task Tag

  1. Go to Window > Preferences > ColdFusion > Profiles > Editor > Task Tags.

  2. Click New.

  3. In the Add Task Tag dialog box, specify a unique name for the custom task tag and then select the priority.

Use the custom tags in the tasks you create as comments.

Removing tasks

Manually delete the tasks from the source code.This is unlike the tasks you manually create in the Task View, which can be deleted in the View itself.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy