Spook
Spook

Reputation: 25929

VS Code snippet - escape ${file}

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?

Upvotes: 24

Views: 11631

Answers (1)

Quentin
Quentin

Reputation: 930

"}" 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

Upvotes: 59

Related Questions