Can I have certain code snippets ready to be inserted?

Yes, first create a →template, then insert this template by using the content assist.

How to create a template for the ST-editor:

  1. In menu Window, select Preferences. Expand the group ST-Object and select Templates.

  2. Click New...

  3. In the dialog, enter the following data as required, then click OK.

    • the template name in field Name

    • the context type for the new template in the Context drop down list
      The context determines where the template can be used and the set of available template variables.

    • check for Automatically insert so that content assist automatically inserts the template, if it is the only proposal available at the code position.

    • a description for the new template in field Description
      This description is displayed as information in the list of the content assist.

    • the code for this template in field Pattern

    • one or more template variables in field Pattern
      Example: The pattern (* created on ${date} by ${user} for ${word_selection} *) creates a comment based on the selected word and adds the date and the ID of the user.
      For each required template variable: Click Insert Variable... and double-click one of the items in the provided list. The list also provides an item to create a new template variable (in field Pattern, enter a name for the inserted, new template variable).

      What is a template variable?

      A template variable marks an editable location in the code of the template. They can be resolves to a concrete value when the code of the template is evaluated in its context. They can also provide a list of alternative proposals valid at the given location.
      For instance, a template variable within a declaration template stands in for the identifier that is needed within a declaration.

How to insert the code of the template:

  1. Position within the ST-code where you need the appropriate ST-code.

  2. Press Ctrl+Space. (This starts the content assist.)

  3. Select the template in the list.

  4. Overwrite possibly included template variables. Press the Tab-key to go to the next template variable or to leave the code of the template.

See "Inhaltshilfe (Code-Assistent oder "Content Assist")" for details on content assist.