Snippets

Nova’s editor supports a format for placeholder management known as the Snippets format. This format is in part based on the TextMate editor’s snippet support. This format allows Nova’s Clips feature and Completions to intelligently insert placeholders into the editor that allow rich user interaction.

API Format Support

The Snippets format is supported in the following places:

Support for the Snippets format was added to the Extension API in Nova 1.2.

Format

The Snippets format uses a special placeholder syntax defined by the use of the dollar sign and (in certain cases) curly braces.

Tab Stops

Tab stops allow the editor cursor to move inside a snippet. Use $0, $1, $2, etc. to specify cursor locations. The number is the order in which tab stops will be visited. Multiple tab stops with the same numeric value are linked and update together as the user types.

Placeholders

Placeholders are tab stops with a visible value, such as ${1:foo}. The placeholder text will be inserted within a token such that it can be chosen by pressing Return while the token is selected.

Variables

With $name or ${name:default} you can insert the value of a variable. When a variable isn’t set, its default or the empty string is inserted. When a variable is unknown (that is, its name isn’t defined) the name of the variable is inserted and it is transformed into a placeholder.

The set of available variables differs depending on which area of the IDE the snippet is being evaluated.

Variables Available to the Extension API

The following variables are supported from snippets in both the Nova Clips JSON format as well as when using the InsertTextFormat.Snippets API: