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?
An extension for VS Code that allows you to escape/unescape quotes in the selected string. After installing the extension, when you select text and right-click on it, a new Escape quotes menu will appear.
Project-folder snippets are created with the New Snippets file for ' '... option in the Preferences: Configure User Snippets dropdown menu and are located at the root of the project in a . vscode folder. Project snippet files are useful for sharing snippets with all users working in that project.
With a code file open in the editor, choose Snippets > Insert Snippet from the right-click menu, then My Code Snippets. You should see a snippet named Square Root. Double-click it. The snippet code is inserted in the code file.
In VS Code, snippets appear in IntelliSense ( Ctrl+Space gives you a suggestion list), they are mixed in with other suggestions. You can also access them in a dedicated snippet picker by using the 'Insert Snippet' command. This combines all user, extension, and built-in snippets for that language into a single list.
"}" 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With