I am trying to create a snippet which includes a $ sign, but in output vscode is skipping the $ sign and making the text selected.
"Color 1": {
"prefix": "c1",
"body": [
"color: $c1;"
]
}
Output
color: c1;
I have also tried using / and ''. Can anyone please guide.
CodePudding user response:
You can escape $
sign in snippets with double backslash \\
like this:
"Color 1": {
"prefix": "c1",
"body": [
"color: \\$c1;"
]
}
CodePudding user response:
From the Snippet Doc page
How do I have a snippet place a variable in the pasted script?
To have a variable in the pasted script, you need to escape the '$'
of the $variable name so that it isn't parsed by the snippet expansion phase.
"VariableSnippet":{
"prefix": "_Var",
"body": "\\$MyVar = 2",
"description": "A basic snippet that places a variable into script with the $ prefix"
}
This results in the pasted snippet as:
$MyVar = 2