Code templates (Ctrl-T)

Code templates are snippets of frequently used code elements available to insert into the code to avoid repetitive typing and speed up coding.

To use a code template in your code, use one of these methods:

  • Type the code template name, such as "case", in your code where you want it to appear. Press Ctrl-T, or right-click and choose Expand Template.
  • Position the cursor where you want the code to appear, press Ctrl-T, and select from the list of code templates.

The selected template is inserted in the document using the exact layout (tabs, linefeeds, and so on.) A corresponding number of lines are shifted.

Templates are user-customizable. Select Tools > Preferences (or, if you are on a Mac, > Preferences), then Code Editor > Code Templates to add or modify a template.

Example: Adding a "case" instruction code template

Use the popup window (Ctrl-T) to select a keyword, or type "case" and press Ctrl-T.

Figure: Code template pop-up window

This figure is a screenshot of a code template pop-up with the case template selected.

The code template is inserted in your code, ready for you to complete.

Figure: CASE code template

This figure shows the Case statement code inserted by the case template: CASE () WHEN WHEN END CASE.