Using templates

To use templates:

  1. In the Java editor, position the caret in a place where you want to insert a template.

  2. Invoke content assist by pressing Ctrl+Space.

  3. Templates appear in the presented list. Note that the list is filtered as you type, so typing a few first characters of a template name will reveal it.

  4. Note that a preview is presented for each selected template.

Notes:

Templates can have variables, which are place-holders for the dynamic part of a template pattern, e.g. subject to change with every application of the particular template.

When a template is inserted in the Java editor and the template pattern contained a template variable, the editor enters the template edit mode.

The first variable is underlined and selected. The variable can be modified by typing in the editor. If the same variable existed multiple times in the template pattern, all instances of the same variable are updated instantaneously to save typing.

Pressing Tab navigates to the next unique template variable, Shift-Tab navigates to the previous unique template variable.

The template edit mode is left by either pressing Tab on the last template variable or pressing Esc or Enter.

Example:

Related concepts
Java editor
Templates

Related tasks
Using the Java editor
Writing your own templates

Related reference
Templates preference page

Legal notices