Posts in Category "Editor"

Enable word wrap

CFBuilder does not have a context sensitive word wrap functionality as of now. To have soft word wrap working for cfml and html files, there’s an eclipse plugin available.
1. Help > Software Updates > Available Software tab -> Add Site
2. Enter the url – http://ahtik.com/eclipse-update/
3. Install
4. Restart CFBuilder
5. Open a cfm or html file.
6. On right-click, you’ll see a context sensitive menu ‘Virtual Word Wrap’.
Hope this helps.

Set your preferences

Set your preference to suit your typing needs:
You can turn off auto activation of code assist through Window-Preferences-ColdFusion-Editor Profiles-Editor-Code Assist. This means that code assist will not be invoked automatically. However, you can invoke it by pressing CTRL+SPACE (or appropriate key combination on Mac) whenever you want. Code assist is an expensive operation and you may choose editor not to do it automatically unless invoked.
You can disable auto-insertion of closing tags.
Window-Preferences-ColdFusion-Editor Profile-Editor-Code Assist- “Automatically Insert a Closing Tag”. Because looking for the matching end tag on typing ‘>’ for the start tag is also an expensive operation. However, if you type </ and invoke code assist manually (by pressing CTRL+SPACE), it is inserted for you, so you don’t have to type closing tag.
Set your preference to reduce CFBuilder launch time:
You may choose to disable building server settings through
Window-Preferences-ColdFusion-Server Settings-Uncheck ‘Build Server Settings’. Since ColdFusion Builder uses server settings to provide code assist (for displaying datasources, resolving CFC names etc), you may choose not to initiate build while it starts. Window-Preferences-Server Settings-Check ‘Build Server Settings’ and Uncheck ‘Initiate Build When ColdFusion Builder Started’. You may choose to intiate building server settings when server is started, added or refreshed.

Setting Background color for comments

Many of you are used to Dreamweaver style color coding.
Check out a nice blog post by my colleague Sandeep Paliwal on setting back ground color for comments here.

Colorization of more than 500 columns in CFBuilder

Some people reported bugs saying CFBuilder does not seem to colorize more than 500 columns. This issue is majorly hit upon by people who have or write single line tag code spanning over many columns. This is not a bug. There is a setting in Preferences to get around this problem.
Go to Window->Preferences->HTML->Editors->Advanced tab->Set ‘Maximum no. of columns to colorize’ as per your requirement. Hope this helps.

Code hyperlinking

Have you tried this out? This is a handy thing indeed and is one of my favorites. Code hyperlinking works on CFCs, UDF calls in local and included files, and CFC methods. Just doing a Ctrl+Click on the CFC or method name takes you to the CFC or the method code respectively. It also works on the template file in <cfinclude> tag. As for CFCs, it works within createObject(), <cfobject>, <cfinvoke>, new operator, and in ‘extends’ and ‘implements’ attributes of cfcomponent. Hyperlinking works with method calls in <cfdump> as well. In addition to these, if you have variables mapping for CFCs in your project, Ctrl+Click-ing on variable_name.CFC_method_name takes you to the method code.

Example on content assist w.r.t Application.cfc

Here’s an example on how scoped variables declared in onApplicationStart method will be available in content assist. Note the scoped variables set in Application.cfc (Application.obj1/obj2/obj4/obj7/qVar/Counter1 in this example) and try getting content assist on them in any file in the application (as shown in test.cfm in this example). Another thing to note here is the various types of CFC variables created. Yes, we have tried to cover some such common variable assignment scenarios. Do try them out and let us know if they work as desired.
— Application.cfc —
<cfcomponent>
<cfset This.name = “TestApplication”>
<cfset This.Sessionmanagement=true>
<cfset This.Sessiontimeout=”#createtimespan(0,0,10,0)#”>
<cfset This.applicationtimeout=”#createtimespan(5,0,0,0)#”>
<cffunction name=”onApplicationStart”>
<cfset Application.obj7 = new component_testing.cfcomponent.component_01()>
<cfset cfcNames.firstName = “component_testing.cfcomponent.component_01″>
<cfset Application.obj1 = createObject(“component”, cfcNames.firstName)>
<cfscript>
cfcNameVar = “component_testing.cfcomponent.component_02″;
Application.obj2 = createobject(“component”, #cfcNamevar#);
foo = createObject(“component”, “com.adobe.coldfusion.mail”);
Application.obj4 = foo;
</cfscript>
<cftry>
<cfquery name=”testDB” dataSource=”cfdocexamples” maxrows=”2″>
SELECT Emp_ID FROM employee
</cfquery>
<cfset Application.qVar = “testDB”>
<cfcatch type=”database”>
<cfdump var=”#cfcatch#”>
</cfcatch>
</cftry>
<cflog file=”#This.Name#” type=”Information” text=”Application Started”>
<cfscript>
Application.availableResources=0;
Application.counter1=1;
Application.sessions=0;
</cfscript>
</cffunction>
</cfcomponent>
— test.cfm —
<cfset Application.availableResources>
<cfset Application.counter1>
<cfset Application.qVar>
<cfset Application.obj1.method_01()>
<cfset Application.obj2.method_11()>
<cfset Application.obj4.addParam()>
<cfset Application.obj7.method_02()>

Content Assist Tips

The advantage of code completion features is that you discover them as and when you type things out in the editor. One does not need to rely much on the documentation part of it. To start off, just thought of listing down couple of features from code assist inventory.
Did you notice…
1. Content assist on CFCs is available on ‘bind’ attributes of tags also? For example, <cfdiv>, <cfgrid>, <cfinput>, <cfselect>, <cfajaxproxy> etc
2. Content assist on variables, UDFs, queries and CFCs of an included file is available on the file including it.
3. Content assist on CFCs is available with ‘new’ operator also.
<cfscript>
myObj = new “myCFC”();
myObj.method1();
</cfscript>
4. Content assist also works on project level variables for CFCs. In project properties, there is a page for ColdFusion variable mappings where you can map variables to fully qualified CFC names. For example, Application.mycfc1 might map to com.adobe.mycfcs.mycfc1. You don’t
need to create objects of this CFCs to get content assist. Application.mycfc1. should give you the methods as Application.mycfc1.mymethod1.
5. Similar to the way file browser shows up in tag attribute values that take in file/dir, content assist shows file browser for relevant functions as well. For example, fileExists(), fileDelete(), fileRead() etc.
6. Content assist processes Application.cfm and Application.cfc. Application.cfm will be treated as included file and all variables and functions will be available for content assist. But in case of Application.cfc, only scoped variables declared in onApplicationStart will be available in content assist.
7. Content assist shows implicit getter and setter functions for properties of CFCs.
For example,
—test.cfc—
component
{
pageencoding “utf8″;
property name=”x” cacheregion=”” collectiontype=”array” cfc=””;
property string y;
param name=”x” pattern=”” default=””;
param y=10 max=””;
//x = new vam();
public void function foo(required x=”hi”)
{
return arguments.x;
}
}
Now try calling method of this component.
<cfset myObj = createObject(“component”, “test”)>
<cfset myObj. shows the methods foo(x), getx(), gety(), setx() and sety()
Try out these features and post your feedback on them. I will post examples on content assist w.r.t Application.cfc soon.