在VSCODE片段中使用$
我正在尝试创建一个包含$标志的片段,但是在输出中,VSCODE跳过$符号并选择文本。
"Color 1": {
"prefix": "c1",
"body": [
"color: $c1;"
]
}
Output
color: c1;
I have also tried using \ and ''.任何人都可以指导。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以逃脱
$
在带有双重拒绝<代码> \\ 的摘要中签名:You can escape
$
sign in snippets with double backslash\\
like this:来自 sminippet doc 页面
如何在粘贴脚本中放置一个变量?
要在粘贴脚本中具有变量,您需要逃脱$变量名称的
'$'
,以使其不会被smippet扩展阶段解析。这导致粘贴片段为:
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.This results in the pasted snippet as: