Skip to main content

En and em dash in VSCode

It turns out we can add some convenient snippets for en dash and em dash in VSCode.

First we need to create a global snippet file by following the steps below:

  • Open up the Command Palette (Ctrl+Shift+P)
  • type user snippets
  • choose Preferences: Configure User Snippets
  • choose New Global Snippets file...
  • enter the name for the global snippet json (here I'll use global.code-snippets.json)

And then create the following key-values inside the json.

global.code-snippets.json
{
"endash": {
"prefix": "!--",
"body": "–"
},
"emdash": {
"prefix": "!---",
"body": "—"
}
}

prefix is a trigger word for body. So every time you type the prefix for a snippet (or substring of it), intelliSense will show you the snippet name; for example, endash or emdash above. Feel free to choose any prefix you want.

IntelliSense can be triggered by Ctrl+Space in any editor window.