24

I'd like to create a snippet in VS Code, which includes exact string ${code}. However, when I enter it in this form, VS Code tries to interpret it as snippet parameter. How should I escape it properly?

Spook
  • 25,318
  • 18
  • 90
  • 167

1 Answers1

56

"}" AND "$" can be escaped with "\\". Some cases "$" can be escaped with "$$" but not in your case.

Your snippet should look like this.

"Return Code With Squirly And Dollar": {
    "prefix": "code_snippet",
    "body" : [
        "\\${code\\}"
    ],
    "description": "Code Snippet"
}

This should help you

Quentin
  • 900
  • 8
  • 13