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?
Asked
Active
Viewed 9,936 times
24

Spook
- 25,318
- 18
- 90
- 167
1 Answers
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
-
1And it definitely did. Thanks! – Spook Mar 09 '17 at 07:11
-
An ES6 string literal example: `"console.log(\`${1:debugEl}: \\${ ${1:debugEl} \\}\`)"` – Tom Jun 11 '17 at 10:01
-
it works!!! vscode version: September 2022 (version 1.72) – Renan Franca Nov 18 '22 at 19:29