From f63224f6b7eb444b0fe96e38ffa63b157d8f43cf Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Mon, 14 Nov 2016 11:46:15 +0100 Subject: [PATCH] snippet features and grammar, #3210 --- .../editor/contrib/snippet/common/snippet.md | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/vs/editor/contrib/snippet/common/snippet.md diff --git a/src/vs/editor/contrib/snippet/common/snippet.md b/src/vs/editor/contrib/snippet/common/snippet.md new file mode 100644 index 00000000000..fd059f82fff --- /dev/null +++ b/src/vs/editor/contrib/snippet/common/snippet.md @@ -0,0 +1,31 @@ + +Tabstops +-- + +With tabstops you can make the editor cursor move inside a snippet. Use `$1`, `$2` to specify cursor locations. The number is the order in which tabstops will be visited, whereas `$0` denotes the final cursor position. Multiple tabstops are linked and updated in sync. + +Placeholders +-- + +Placeholders are tabstops with values, like `${1:foo}`. The placeholder text will be inserted and selected such that it can be easily changed. Placeholders can nested, like `${1:another ${2:placeholder}}`. + +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. + + +Grammar +-- + +Below is the EBNF for snippets. The `$`-character can be escaped using backslash, like `\$`. + +``` +any ::= tabstop | placeholder | variable | text +tabstop ::= '$' int +placeholder ::= '${' int '}' | '${' int ':' any '}' +variable ::= '$' var | '${' var }' | '${' var ':' any '}' +var ::= [_a-zA-Z] [_a-zA-Z0-9]* +int ::= [0-9]+ +text ::= .* +``` -- GitLab