Templates and snippets can boost your productivity by supplying you with some code snippets right at your fingertips (by pressing CTRL+Space in the edtior).

The Snippets view shows you all defined snippets. You will probably want to have your code skeletons for programs and procedures in that view for easily setting up and start development of your new program.

Creating Templates

Templates and snippets can be easily created in the preferences, see Main Menu → Window → Preferences → Editor → Templates.

Templates must be assigned a category (CL, RPG or Snippets). A template with the category CL will only be available in a CL editor (either QSYS or Stream File). Templates with the category Snippets are only available in the Snippets view.

Template Variables

Templates are not only static text but can also have variable content, variables. Template variables start with ${ and end with }. F. e.

${description}

There are five special variables:

  • ${date} -- is resolved to the current date
  • ${user} -- is resolved to the current license user
  • ${cursor} -- this is the position where the cursor is placed after exiting the special editing mode
  • ${word_selection} -- is resolved to the current selected text in the editor (it may span multiple lines)
  • ${line_selection} -- is resolved to the first character of the first line to the last character of the last line from the selected text

The template variables are placeholders which will be resolved to a value or will be placed into the source code as placeholders which the user can fill after inserting the template. After inserting the template the editor is switched to a special mode where the user can enter a value for each non resolved placeholder. The TAB character is used to move to the next placeholder. ALT+TAB is used to move to the previous placeholder.

If a placeholder exists multiple times in a template all those occurences are edited simultanesouly.

Surround With Editor Support

The context menu of each editor has also the menu entry Surround With. Under this menu entry are the templates listed which contain either the variable ${word_selection} or ${line_selection} and from this menu entry can these templates be used.

Import / Export

The templates section in the Preferences dialog has buttons for importing and exporting templates. The templates are stored in a text file in XML format for an easy exchange of templates.

Templates are identified by their name. If a template is imported into an editor installation any existing template with this name will be replaced with the new one.