Snippets
Snippets register reusable code templates with Monaco as completions for a given language. They're pure JSON in the VS Code-compatible format — no code, no main, no activation events.
1. Declare the snippet set
Each entry binds a snippet file to a Monaco language id:
"contributes": {
"snippets": [
{ "language": "javascript", "path": "snippets/javascript.json" }
]
}| Field | Required | Notes |
|---|---|---|
language | yes | Monaco language id (e.g. javascript, python, css). |
path | yes | Relative path to the snippet JSON, inside the archive. |
Aero registers the file as a completion provider for that language.
2. The snippet file
The file uses the VS Code-compatible shape: an object keyed by snippet name, each with a prefix, a body, and an optional description.
{
"Log to console": {
"prefix": "log",
"body": ["console.log('$1', $1);", "$0"],
"description": "Console log a value"
}
}| Field | Type | Meaning |
|---|---|---|
prefix | string | The trigger text the user types. |
body | string or string[] | The inserted template; an array joins with \n. |
description | string | Shown in the completion list. |
3. Tab stops & placeholders
Bodies support Monaco/TextMate snippet syntax:
| Syntax | Meaning |
|---|---|
$1, $2, … | Ordered tab stops — press Tab to jump between them. |
${1:label} | A tab stop with default/placeholder text label. |
$0 | The final cursor position after all tab stops. |
$1 repeated | Repeating a stop number mirrors typing across them. |
Example with a placeholder and a mirrored stop:
{
"For loop": {
"prefix": "for",
"body": [
"for (let ${1:i} = 0; ${1:i} < ${2:length}; ${1:i}++) {",
"\t$0",
"}"
],
"description": "A counting for-loop"
}
}Typing for then accepting the completion lets the author tab through i (mirrored in three places), then length, and finally land at $0 inside the loop body.
4. Multiple languages
Contribute one entry per language, each pointing at its own file:
"snippets": [
{ "language": "javascript", "path": "snippets/javascript.json" },
{ "language": "typescript", "path": "snippets/typescript.json" },
{ "language": "css", "path": "snippets/css.json" }
]5. Using snippets
Open a file of the target language, type a prefix, and accept the suggestion from Monaco's completion list. Tab moves through the stops in order, ending at $0.
Related
- Manifest reference — the schema.
- Examples — a snippet file inside a full extension.