VS Code snippet - escape ${file}
Asked Answered
C

1

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?

Carotenoid answered 8/3, 2017 at 10:58 Comment(0)
T
59

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

Tic answered 8/3, 2017 at 13:26 Comment(1)
An ES6 string literal example: "console.log(`${1:debugEl}: \\${ ${1:debugEl} \\}`)"Petulah

© 2022 - 2024 — McMap. All rights reserved.