TeraTech

The ColdFusion Experts: Develop | Secure | Optimize

  • Services
  • About
  • CF Alive
  • Blog
  • Podcast
  • Contact

  • Services
  • About
  • CF Alive
  • Blog
  • Podcast
  • Contact

What is CFeclipse Snippets and How to Use It?

October 9, 2022 By Michaela Light Leave a Comment

CFeclipse Snippets

As a programmer you find many times with the need to write the same code again and again for each component or file, or within the same file when defining functions, for example, all have the same format or syntax, you can copy and paste but there are ways More convenient like Snippets, which are stored predefined code blocks which can be inserted with some combinations of characters predefined by the user in conjunction with key combinations or shortcuts; Many IDE's have this function and Eclipse is not far behind for example whenever I want to insert the definition of a function write the word function and then press the keys ctrl + j, this opens a window with fields like name, displayname, hint , ReturnType, access; Once the fields are filled I press OK and I get the definition of a function ready to start with the code of the body of this one.

Let's for example to create a snippet to insert the init function that is occupied in all components as the object constructor, if you are using Object Oriented Programming, if you do not use it, you should.

To define a variable, which will be converted to a field in the window that needs to be filled at the time of inserting the snippet, is used $$ {Setting: variable not found}; Then the snippet would be defined as follows:

*Note. This is my way of defining and documenting functions is not a rule but you can take it as an example

 

/**

*@Displayname $${Setting: displaname not found}

* $${Setting: hint not found}

*

**/

 

$${Setting: access:private|public|remote not found} $${Setting: returntype:any|array|boolean|numeric|struct|void not found} function $${Setting: name not found}(){

 

   return;

}

 

In the previous example we find something like this: {setting: access | private | public | remote not found} with this we are indicating that the variable access can have the following values private, public, remote then at the time of inserting the snippet, Eclipse Will show a drop-down list with these options in the window, but if you need to write something different to any of these options you can do so.

 

Eclipse allows you to organize snippets into packages so you can group them by language, functionality or as you see fit.

Steps to Create a CFeclipse Snippet

  1. Show the snippets panel, in the default perspective of CFeclipse, can be found in the left toolbar or in the main menu Window – Show view – Snip Tree View
  2. Click on the New snippet icon
  3. Write the name of the snippet (Snippet name)
  4. Write the text that will trigger the insertion of the snippet (trigger text), to insert a snippet can be from the corresponding panel, or typing the trigger text and pressing the keys ctrl + j
  5. In the window, two text areas are offered for the body of the snippet, this is because in markup languages an opening tag and a closing tag are occupied, then when a snippet is created using the two fields, at the time of insertion, Text that is selected will be enclosed by first inserting the first block (starting block), and then the second (closing block), for functions for example only the first field (starting block) will be used.

Steps to insert a CFeclipse snippet

First Method

  1. Position the cursor in the place where you want to insert the snippet.
  2. Locate the snippet in the panel and click on it to select it.
  3. Click on the Insert snippet icon

Second method

  1. Position the cursor in the place where you want to insert the snippet
  2. Write the trigger text corresponding to the snippet at the time of creating it and press ctrl + j the trigger text is case sensitive, if no variable was defined in the snippet, the snippet body text will be inserted, otherwise a window will appear for Write the corresponding variables.

If you want to backup your snippets, share them, or add someone else's, just copy the files to or from the following path <workspacelocation> /workspace/.metadata/.plugins/org.cfeclipse.cfml/snippets; There you will find XML files organized in folders that are the packages that you created. By default the <workspace location> path is /users/[username]/documents/

Remember that the workspace was defined the first time you ran Eclipse, or whenever you open it, if you did not activate the Always use this path.

Download some Snippets here.

Links of Interest for CFeclipse

Https://github.com/cfeclipse/CFEclipse/wiki/code-snippets

 

 

  • Facebook
  • Twitter
  • LinkedIn

Related Posts

  • CFEclipse cheatsheet
  • CFEclipse 1.3 Update - Part II
  • CFEclipse 1.3 Update - Part I
  • ColdFusion Database Performance Tuning
  • ColdFusion: Introduction to FusionReactor

Filed Under: Uncategorized

← Previous Post State of The CF Union Analysis part 2 – Transcript
Next Post → Adobe ColdFusion and the Fear of Change

Popular podcast episodes

  • Revealing ColdFusion 2021 – Rakshith Naresh
  • CF and Angular – Nolan Erck
  • Migrating legacy CFML – Nolan Erck
  • Adobe API manager – Brian Sappey
  • Improve your CFML code – Kai Koenig

CF Alive Best Practices Checklist

Modern ColdFusion development best practices that reduce stress, inefficiency, project lifecycle costs while simultaneously increasing project velocity and innovation.

Get your checklist

Top articles

  • CF Hosting (independent guide)
  • What is Adobe ColdFusion
  • Is Lucee CFML now better than ACF?
  • Is CF dead?
  • Learn CF (comprehensive list of resources)

Recent Posts

  • Protected: State of the CF Union 2022 Survey Released
  • 127 Modernizing ColdFusion apps (through evolution, not revolution) with Guust Nieuwenhuis
  • 126 Revealing FusionReactor 9 (ColdFusion Monitoring New Tools) with David Tattersall
  • Adobe ColdFusion 2023 Major Announcement- Codename Fortuna (Alpha, Pre- Release, Testing)
  • 125 State CF Union Survey Analysis (part 3: Community, Deployment and Wrapup) with Gavin Pickin

Categories

  • Adobe ColdFusion 11 and older
  • Adobe ColdFusion 2018
  • Adobe ColdFusion 2020 Beta
  • Adobe ColdFusion 2021
  • Adobe ColdFusion 2023
  • Adobe ColdFusion Developer week
  • Adobe ColdFusion Project Stratus
  • Adobe ColdFusion Summit
  • AWS
  • CF Alive
  • CF Alive Podcast
  • CF Camp
  • CF Tags
  • CF Vs. Other Languages
  • CFEclipse
  • CFML
  • CFML Open- Source
  • CFUnited
  • ColdBox
  • ColdFusion and other news
  • ColdFusion Community
  • ColdFusion Conference
  • ColdFusion Consulting
  • ColdFusion Developer
  • ColdFusion Development
  • ColdFusion Hosting
  • ColdFusion Maintenance
  • ColdFusion Performance Tuning
  • ColdFusion Projects
  • ColdFusion Roadmap
  • ColdFusion Security
  • ColdFusion Training
  • CommandBox
  • Docker
  • Fixinator
  • Frameworks
  • Fusebox
  • FusionReactor
  • IntoTheBox Conference
  • Java
  • JavaScript
  • JVM
  • Learn CFML
  • Learn ColdFusion
  • Legacy Code
  • Load Testing
  • Lucee
  • Mindmapping
  • MockBox
  • Modernize ColdFusion
  • Ortus Developer Week
  • Ortus Roadshow
  • Server Crash
  • Server Software
  • Server Tuning
  • SQL
  • Survey
  • Survey results
  • TestBox
  • Transcript
  • Uncategorized
  • Webinar
  • Women in Tech
  • Home
  • Services
    • ColdFusion Consulting
    • ColdFusion Development
    • ColdFusion Maintenance
    • ColdFusion Security
  • About Us
  • CF Alive
    • CF Alive Book
    • CF Alive Inner Circle
    • CF Alive full resources cheatsheet
  • Blog
  • Podcast
    • Podcast Guest schedule
  • Contact
  • Sitemap

The ColdFusion Experts:
Develop, Secure, Optimize

TeraTech Inc
451 Hungerford Drive Suite 119
Rockville, MD 20850

Tel : +1 (301) 424 3903
Fax: +1 (301) 762 8185

Follow us on Facebook Follow us on LinkedIn Follow us on Twitter Follow us on Pinterest Follow us on YouTube

 

(Gandalf, the CF wizard,

can often be found in Hobbiton)

Copyright © 1998–2023 TeraTech Inc. All rights Reserved.