Adding shortcuts for snippets in VSCode

September 29, 2023

In snippets file:

{
  "Current Date": {
    "prefix": "Current Date",
    "description": "Insert current date",
    "body": [
      "## $CURRENT_YEAR-$CURRENT_MONTH-${CURRENT_DATE} (${CURRENT_DAY_NAME})",
      "",
      ""
    ]
  },
  "Daily Note": {
    "prefix": ["Daily Note"],
    "description": "Insert note",
    "body": [
      "### ${1}",
      "",
      "- metadata: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE ($CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND), ${3}",
      "- description: ${2}",
      "",
      "---",
      "",
      "${4}"
    ]
  }
}

In keybindings file:

[
  {
    "key": "ctrl+k d",
    "command": "editor.action.insertSnippet",
    "when": "editorTextFocus",
    "args": {
      "name": "Current Date"
    }
  },
  {
    "key": "ctrl+k n",
    "command": "editor.action.insertSnippet",
    "when": "editorTextFocus",
    "args": {
      "name": "Daily Note"
    }
  }
]