json - 在 VScode 代码片段中添加美元符号 ($)

标签 json vscode-snippets

我正在为 VScode 中的 verilog 文件编写自定义代码片段; VSCode 为此使用 JSON 文件。
我观察到 $ before finish 和 dumpvars 语句在我使用该代码段时不会被打印出来,因为它是一个内置关键字,用于在 json 文件格式的字符串中包含变量, 我试过在 $ 之前添加\但那没有 起作用。
有什么方法可以在我的代码片段中插入 $ 吗?

这是我正在使用的相关代码块:

"dump statements": {
        "prefix": "dump",
        "body": [
            "initial begin", 
            "   dumpfile(\"${1:filename}\");",
            "   \$dumpvars();",
            "end"
        ],
        "description": "Prints the dump file and variables statements."
    },

最佳答案

使用双反斜杠对其进行转义,例如 \\$

"dump statements": {
    "prefix": "dump",
    "body": [
        "initial begin", 
        "   dumpfile(\"${1:filename}\");",
        "   \\$dumpvars();",
        "end"
    ],
    "description": "Prints the dump file and variables statements."
},

关于json - 在 VScode 代码片段中添加美元符号 ($),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72274207/

相关文章:

html - 在脚本标签中嵌入 JSON 对象

objective-c - quickDialog 表单的通用类

regex - 为 C++ header guard 实现 VSCode 片段

visual-studio-code - 创建VSCode代码段时,如何将变量转换为标题大小写(如TitleCase)?

visual-studio-code - 在我的自定义片段中使用 TM_SELECTED_TEXT

linux - sed 不匹配的返回值

json - 使用 jq select 元素和包含一些字符串的键,键保留在结果中

xml - 调用 Jersey api 时无法指定接受哪种响应类型

reactjs - VSCode 用户片段为 React 生成 useState?

visual-studio-code - vscode 片段中的 const case