Skip to main content
Version: 2.0.0 (latest)

4.5. Snippets settings

pgModeler supports code snippets, which are text fragments mainly used to avoid repetitive code typing when managing databases via the SQL tool on the Manage view. Snippets can be written in the form of pure SQL commands or using a special set of commands known as schema microlanguage (detailed in Appendix I: Schema microlanguage), a simple programming language used internally by pgModeler to generate code. To provide users a way to store their own code snippets, pgModeler implements a snippet configuration widget. The widget groups snippets by object type and also provides basic code validation when writing snippets in the schema microlanguage.

ch4.snippets-settings1234567891011121314

Snippets
#FieldDescription
1Filter

Filters the list of snippets by category (All snippets, General purpose, or an object type).

2Snippets

Lists all the available snippets. The New button, which starts a new snippet, is not shown in the capture because it is hidden while a snippet is being edited. The other buttons beside the list are described below.

3Cancel edition

Cancel : cancels the editing of the selected snippet.

4Edit snippet

Edit : loads the selected snippet in the fields below so it can be edited.

5Delete snippet

Delete : deletes the selected snippet.

6Delete all snippets

Delete all : deletes all the snippets.

Snippet properties
#FieldDescription
7Snippet id

The unique identifier of the snippet. It is listed in the code completion widget and is used to insert the code of the snippet in any source code field.

8Label

A brief description of the snippet.

9Applies to

The category or object type the snippet belongs to. General purpose is used for snippets that are not related to an object type.

10Is parsable

Indicates that the snippet is written in the schema micro language syntax and needs to be parsed. In a parsable snippet, the attributes enclosed by {} are replaced by the matching attributes of the object selected in the database explorer of the Manage view.

11Allow placeholders

When a parsable snippet is handled, the empty attributes are replaced by a value in the format {attribute}. Note that this option can change the semantics of the resulting snippet.

12Parse

Parse : parses the snippet to check for syntax errors. It is enabled only for parsable snippets.

13Add / Update

Add / Update : adds the snippet configured in the form to the list or, while a snippet is being edited, replaces it with the one configured in the form (the button takes the place of Add during the edition). It is enabled when the id, the label, and the code are filled.

14Snippet code

The code of the snippet. Parsable snippets can use the attributes of the object enclosed by {} as placeholders. The bar above the editor has the buttons Load , Save , Copy , Edit (opens the text in the external editor), Search , Wrap , and Clear .