Skip to content

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:

json
"contributes": {
  "snippets": [
    { "language": "javascript", "path": "snippets/javascript.json" }
  ]
}
FieldRequiredNotes
languageyesMonaco language id (e.g. javascript, python, css).
pathyesRelative 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.

json
{
  "Log to console": {
    "prefix": "log",
    "body": ["console.log('$1', $1);", "$0"],
    "description": "Console log a value"
  }
}
FieldTypeMeaning
prefixstringThe trigger text the user types.
bodystring or string[]The inserted template; an array joins with \n.
descriptionstringShown in the completion list.

3. Tab stops & placeholders

Bodies support Monaco/TextMate snippet syntax:

SyntaxMeaning
$1, $2, …Ordered tab stops — press Tab to jump between them.
${1:label}A tab stop with default/placeholder text label.
$0The final cursor position after all tab stops.
$1 repeatedRepeating a stop number mirrors typing across them.

Example with a placeholder and a mirrored stop:

json
{
  "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:

json
"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.

Lean, AI-ready, under your control.