Using Editor Templates
Editor Templates can be used to easily insert text that you often use, such as code snippets, current date and time, or anything you like.
Only in DbVisualizer Pro
This feature is only available in the DbVisualizer Pro edition.
Using a Template
A template is an Abbreviation that can easily be replaced by its Expanded Text, and it may optionally have a Description.
To expand a template use the Ctrl+Shift-T key binding. This displays a list of matching templates that you can pick from, along with the description or a part of the corresponding expanded text for each.
Select a template by pressing the TAB or ENTER key and it will be expanded in the editor.
You can also enable Instant Substitution to immediately expand the text if you have typed enough of the abbreviation to match a single template when you press the TAB key:
- Open Tools->Tool Properties,
- Select the General/SQL Commander/Editor Templates category,
- Click the Instant Substitution checkbox in the toolbar,
- Click the Apply or OK button to save the updated setting.
You can use the Show Editor Templates entry in the main Edit menu or the editor right-click menu.
Creating a new Template
DbVisualizer comes with some default templates, but you can create additional templates:
- Open Tools->Tool Properties,
- Select the General/SQL Commander/Editor Templates category,
- Click the Insert button in the toolbar to add a new template, and enter an Abbreviation, Expanded Text, and optionally a Description,
- Check off the checkbox in the Format column if you want the Expanded Text to be formatted by the SQL Formatter when it is inserted in the editor,
- Click the Apply or OK button to save the new templates.
If you want to use an existing template as a starting point, you can select it and then click the Duplicate button instead of the Insert button. The Edit in Window button opens the selected cell in a separate window where it is easier to work with larger templates.
Always use a special character, such as dot or hashmark, as the first character in the Abbreviation. The default templates use a dot but you can pick any special character you like. If you use a regular character as the first character, unexpected matches may be found if one abbreviation starts with the same characters as another abbreviation ends with.
Editing or Deleting a Template
You can edit any piece of a template or delete templates you no longer need:
- Open Tools->Tool Properties,
- Select the General/SQL Commander/Editor Templates category,
- To edit, double-click any cell you want to change and edit its value,
- To delete a template, select any of its cells and click the Delete button,
- Click the Apply or OK button to save the changes.
Changing the Expand Keybinding
The keyboard shortcut used to expand a template, or bring up the list of matching templates if more than one, is the TAB key. You can add other shortcuts or change the default, as described in Changing Keyboard Shortcuts. The shortcut is named Show Editor Templates and you find it in the Main Menu/Edit category.