githubEdit

snippets in VSCode

What are snippets in VS Code?

Snippets are reusable text templates triggered by a short keyword (prefix). They:

  • expand into predefined text

  • support variables (like dates)

  • allow placeholders and cursor jumps

You define them in a JSON file (I like to use a separate .vscode/workspace-name-code.snippets), usually scoped to a language like Markdown or AsciiDoc.

Sample snippets

tdy → insert today’s date

Purpose: Quickly insert the current date in ISO format (YYYY-MM-DD), useful for logs, notes, changelogs.

How it works: Uses built-in VS Code variables for year, month, and day.

chevron-rightClick to see code...hashtag
.vscode/workspace-name-code.snippets
{
"today" : {
  "scope": "markdown",
  "prefix": "tdy",
  "body": "${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}"
  }
}

week → weekly notes template

Purpose: Generate a structured weekly note with placeholders and repeated sections.

chevron-rightClick to see code...hashtag

Key features:

  • $1 → first cursor position (e.g. week number)

  • tdy inside template → can be expanded further after insertion

  • consistent daily structure

  • integrates with linking (e.g. [daily])

Usage flow:

  1. Type week → expand snippet

  2. Fill in week number

  3. Expand tdy per day if needed

  • Extensions: Markdown All in One, Markdown Preview Enhanced

Notes

  • Snippets compound well (e.g. week + tdy)

  • Keep prefixes short but unambiguous

  • Use placeholders ($1, $2) for structured input

  • Treat snippets as part of your writing "toolbelt", not just automation

See also

  • VS Code → User Snippets (Ctrl + Shift + P → “Configure User Snippets”)

  • Markdown preview (Ctrl + Shift + V)

Last updated