mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-26 01:38:40 +01:00
Update documentation.
This commit is contained in:
@@ -53,6 +53,26 @@ ${TM_FILENAME/(.*)\..+$/$1/}
|
||||
|-> resolves to the filename
|
||||
```
|
||||
|
||||
Placeholder-Transform
|
||||
--
|
||||
|
||||
Like a Variable-Transform, a transformation of a placeholder allows changing the inserted text for the placeholder when moving to the next tab stop.
|
||||
The inserted text is matched with the regular expression and the match or matches - depending on the options - are replaced with the specified replacement format text.
|
||||
Every occurrence of a placeholder can define its own transformation independently using the value of the first placeholder.
|
||||
The format for Placeholder-Transforms is the same as for Variable-Transforms.
|
||||
|
||||
The following sample removes an underscore at the beginning of the text. `_transform` becomes `transform`.
|
||||
|
||||
```
|
||||
${1/^_(.*)/$1/}
|
||||
| | | |-> No options
|
||||
| | |
|
||||
| | |-> Replace it with the first capture group
|
||||
| |
|
||||
| |-> Regular expression to capture everything after the underscore
|
||||
|
|
||||
|-> Placeholder Index
|
||||
```
|
||||
|
||||
Grammar
|
||||
--
|
||||
@@ -61,12 +81,17 @@ Below is the EBNF for snippets. With `\` (backslash) you can escape `$`, `}` and
|
||||
|
||||
```
|
||||
any ::= tabstop | placeholder | choice | variable | text
|
||||
tabstop ::= '$' int | '${' int '}'
|
||||
tabstop ::= '$' int
|
||||
| '${' int '}'
|
||||
| '${' int transform '}'
|
||||
placeholder ::= '${' int ':' any '}'
|
||||
| '${' int ':' any transform '}'
|
||||
choice ::= '${' int '|' text (',' text)* '|}'
|
||||
| '${' int '|' text (',' text)* '|' transform '}'
|
||||
variable ::= '$' var | '${' var }'
|
||||
| '${' var ':' any '}'
|
||||
| '${' var '/' regex '/' (format | text)+ '/' options '}'
|
||||
| '${' var transform '}'
|
||||
transform ::= '/' regex '/' (format | text)+ '/' options
|
||||
format ::= '$' int | '${' int '}'
|
||||
| '${' int ':' '/upcase' | '/downcase' | '/capitalize' '}'
|
||||
| '${' int ':+' if '}'
|
||||
@@ -78,3 +103,5 @@ var ::= [_a-zA-Z] [_a-zA-Z0-9]*
|
||||
int ::= [0-9]+
|
||||
text ::= .*
|
||||
```
|
||||
|
||||
Transformations for placeholders and choices are an extension to the TextMate snippet grammar and only support by Visual Studio Code.
|
||||
Reference in New Issue
Block a user