Code Templates Preferences

Code templates are code fragments that can be inserted at the current editing position. Oxygen XML Author Eclipse plugin includes a set of built-in templates for CSS, Schematron, XSL, XQuery, JSON, HTML, and XML Schema document types. You can also define your own code templates for any type of file and share them with your colleagues using the template export and import functions.

To configure Code Templates, open the Preferences dialog box and go to Editor > Templates > Code Templates.

This preferences page contains a list of all the available code templates (both built-in and custom created ones) and a code preview area. You can disable any code template by deselecting it.

The following actions are available:

New
Opens the Code template dialog box that allows you to define a new code template. You can define the following fields:
  • Name - The name of the code template.
  • Description - [Optional] The description of the code template that will appear in the Code Templates preferences page and in the tooltip message when selecting it from the Content Completion Assistant. HTML markup can be used for better rendering.
  • Associate with - You can choose to set the code template to be associated with a specific type of editor or for all editor types.
  • Shortcut key - [Optional] If you want to assign a shortcut key that can be used to insert the code template, place the cursor in the Shortcut key field and press the desired key combination on your keyboard. Use the Clear button if you make a mistake. If the Enable platform-independent shortcut keys checkbox is selected, the shortcut is platform-independent and the following modifiers are used:
    • M1 represents the Command key on macOS, and the Ctrl key on other platforms.
    • M2 represents the Shift key.
    • M3 represents the Option key on macOS, and the Alt key on other platforms.
    • M4 represents the Ctrl key on macOS, and is undefined on other platforms.
  • Content - Text box where you define the content that is used when the code template is inserted. An editor variable can be inserted in the text box using the Insert Editor Variables button.
Edit
Opens the Code template dialog box and allows you to edit an existing code template. You can edit the following fields:
  • Description - [Optional] The description of the code template that will appear in the Code Templates preferences page and in the tooltip message when selecting it from the Content Completion Assistant. HTML markup can be used for better rendering.
  • Shortcut key - [Optional] If you want to assign a shortcut key that can be used to insert the code template, place the cursor in the Shortcut key field and press the desired key combination on your keyboard. Use the Clear button if you make a mistake. If the Enable platform-independent shortcut keys checkbox is selected, the shortcut is platform-independent and the following modifiers are used:
    • M1 represents the Command key on macOS, and the Ctrl key on other platforms.
    • M2 represents the Shift key.
    • M3 represents the Option key on macOS, and the Alt key on other platforms.
    • M4 represents the Ctrl key on macOS, and is undefined on other platforms.
  • Content - Text box where you define the content that is used when the code template is inserted. An editor variable can be inserted in the text box using the Insert Editor Variables button.
Duplicate
Creates a duplicate of the currently selected code template.
Delete
Deletes the currently selected code template. This action is not available for the built-in code templates.
Export
Exports a file with code templates.
Import
Imports a file with code templates that was created by the Export action.
You can use the following editor variables when you define a code template in the Content text box: