Code templates are a way to insert large pieces of code at once. Each code templates is identified by a unique name. This name can be used to insert the associated piece of code in the text.
For example, the name ifthen could be associated to the following piece of code:
A code template can be inserted by typing its name, and pressing Ctrl-J when the cursor is positioned right after the template name.
If there is no template name before the cursor, a dialog will pop up to allow selection of a template.
If a vertical bar (—) is present in the code template, the cursor is positioned on it, and the vertical bar is deleted. In the above example, the cursor would be positioned between the if and then, ready to type an expression.
Code templates can be added and edited in the code templates dialog, reachable via the menu option ”Options—Environment—CodeTemplates”. The code templates dialog is shown in figure (6.6).
The top listbox in the code templates dialog shows the names of all known templates. The bottom half of the dialog shows the text associated with the currently highlighted code template. The following buttons are available:
All templates are saved and are available the next time the IDE is started.
Remark Duplicates are not allowed. If an attempt is made to add a duplicate name to the list, an error will occur.