Snippets

Snippets allow you to define re-usable templates to speed up writing code.

To create a snippet:

To insert a snippet:

Syntax

Snippets consist of text with @name placeholders and @{...} expressions.

Example

Here is an example snippet for a JavaScript function:

function @name(@args) {
	@body
}

Each @... placeholder creates a tabstop to be filled in, and starts off empty.

Names can be repeated, in which case they receive the value of the initial tabstop and are updated as you fill it in. For example, here is a snippet for a JavaScript require:

let @name = require("@{path:"./"}@name");@$

Notice that @name appears twice. The second instance will be automatically updated as the first instance is filled in, and will not have its own tabstop.

The require example also uses a default value — see below for details.

Note: the @$ placeholder at the end is just a regular placeholder called $, and is used to allow tabbing to the end of the snippet (otherwise pressing Tab after filling in the path placeholder would insert a literal tab).

Default values

Placeholders can have default values, which are JavaScript expressions (see Expressions below). The syntax is @{name:defaultValue}, where name is the name of the tabstop and defaultValue is a JavaScript expression to use as the default value.

Expressions

Snippets can contain JavaScript expressions enclosed within @{...}. These expressions have access to the values of tabstops, as well as some utility functions [TODO].