A snippet string is a template which allows to insert text and to control the editor cursor when insertion happens.

A snippet can define tab stops and placeholders with $1, $2 and ${3:foo}. $0 defines the final tab stop, it defaults to the end of the snippet. Variables are defined with $name and ${name:default value}. The full snippet syntax is documented here.

Constructor

new(?value:String)

Variables

value:String

The snippet string.

Methods

appendChoice(values:Array<String>, ?number:Int):SnippetString

Builder-function that appends a choice (`${1a,b,c}`) to

the {@linkcode SnippetString.value value} of this snippet string.

Parameters:

values

The values for choices - the array of strings

number

The number of this tabstop, defaults to an auto-increment value starting at 1.

Returns:

This snippet string.

appendPlaceholder(value:EitherType<String, SnippetString ‑> Any>, ?number:Int):SnippetString

Builder-function that appends a placeholder (${1:value}) to the {@linkcode SnippetString.value value} of this snippet string.

Parameters:

value

The value of this placeholder - either a string or a function with which a nested snippet can be created.

number

The number of this tabstop, defaults to an auto-increment value starting at 1.

Returns:

This snippet string.

appendTabstop(?number:Int):SnippetString

Builder-function that appends a tabstop ($1, $2 etc) to the {@linkcode SnippetString.value value} of this snippet string.

Parameters:

number

The number of this tabstop, defaults to an auto-increment value starting at 1.

Returns:

This snippet string.

appendText(string:String):SnippetString

Builder-function that appends the given string to the {@linkcode SnippetString.value value} of this snippet string.

Parameters:

string

A value to append 'as given'. The string will be escaped.

Returns:

This snippet string.

appendVariable(name:String, defaultValue:EitherType<String, SnippetString ‑> Any>):SnippetString

Builder-function that appends a variable (${VAR}) to the {@linkcode SnippetString.value value} of this snippet string.

Parameters:

name

The name of the variable - excluding the $.

defaultValue

The default value which is used when the variable name cannot be resolved - either a string or a function with which a nested snippet can be created.

Returns:

This snippet string.