Earlier this week I was trying to create a new ColdFusion Builder snippet that would insert the current date and time along with my initials into an open template. After inserting the snippet I wanted my cursor to be positioned in the middle of the comment so I could immediately begin writing some notes.

I thought this was done by using the start text and end text fields in the Snippet dialog but no matter what I tried it wouldn't work. ColdFusion Builder, or perhaps Eclipse itself, kept trimming line breaks from both the start text and end text. After a few minutes of frustration I decided to edit the snippet manually.

I opened the Eclipse preferences window and typed snippet into the search box. Then I clicked the menu option for ColdFusion Snippets so I could get the path to my snippets folder.

Finally, I opened my new snippet in MacVim and manually added the needed line breaks at the end of the start text XML node. You can see the line break between lines 6 and 7 in the screenshot below.

All that was left was refreshing the Snippets panel in ColdFusion Builder. While this whole process worked it sure seemed like a lot of effort. And I know I've created dozens of snippets like this in the past that I'm sure didn't require editing outside of Eclipse. Admittedly, those snippets were probably created with CFEclipse and not ColdFusion Builder. If anyone knows a better way would you mind posting a comment to this post? Thanks!

Aaron West's Gravatar
About this post:

This entry was posted by Aaron West on April 18, 2011 at 9:00 AM. It was filed in the following categories: ColdFusion, ColdFusion Builder. It has been viewed 21775 times and has 6 comments.

6 Responses to How to Position the Cursor in the Middle of a ColdFusion Builder Snippet

  1. Try creating the empty lines / line breaks in the snippet by hitting Shift-Enter instead of just Enter. That seems to preserve the empty lines, and if you add a blank line at the start of the End Block it looks like that's where the cursor will end up when the snippet is executed.

  2. Brian, I tried your suggestion using shift+enter and that didn't make a difference. Neither did the blank line suggestion in the end text which is what I thought would've worked as I recall it working in the past. What version of CF Builder are you using?

  3. I'm using the beta of CF Builder 2 (sorry, I didn't mention that because I assumed we were only talking about CF Builder 2).

  4. For most of my development I'm using CF Builder 1 update 1. Good to know this snippet problem occurs in both versions. Thanks Brian.

  5. Jay Dee

    During last weeks CF Builder webcasts, specifically one on CFBuilder, it was mentioned that $${CP} (dollar, dollar, open curly brace "CP", for cursor position, close curly brace) would position the cursor.
    Didn't work for me, just added a dialogue item as other variable definitions did.
    So, still searching myself.

  6. Jay Dee

    OK, was trying to remember this to clean up some old snippets and revisited it. In ColdFusion Builder 2, the control-enter works for me. I also tried "<cfset" in the start block and " $${} />" in the close block Dollar Dollar open brace close brace slash greater-than sign in case the code doesn't display. It pops an empty dialog that I have to press return or click "OK", but it leaves my cursor in the right place with no extra line breaks like the control-enter does...