【问题标题】:Snippet with ANSI terminal escape color codes in VSCODEVSCODE 中带有 ANSI 终端转义颜色代码的片段
【发布时间】:2021-01-14 01:36:33
【问题描述】:

我正在尝试创建自定义 sn-p 以使用 console.log(),并且我正在使用一些 Ascii 代码,因为我想将第一个记录的值设为黄色。

所以我的问题是来自 VSCode 的 snippets.json 文件无法读取 \x1b[33m%s\x1b[0m

我想知道是否有办法从snippets.json 文件中读取Ascii 代码。

https://voidcanvas.com/make-console-log-output-colorful-and-stylish-in-browser-node/

 "Print to console": {
        "prefix": "lg",
        "body": [
             "console.log("\x1b[33m%s\x1b[0m",'$1', $2);",
        ],
        "description": "Log output to console"
     }

【问题讨论】:

    标签: json visual-studio-code ascii code-snippets vscode-snippets


    【解决方案1】:

    您必须转义 "\

    "Print to console": {
      "prefix": "lg",
      "body": [
           "console.log(\"\\x1b[33m%s\\x1b[0m\", '$1', $2);",
      ],
      "description": "Log output to console"
    }
    

    【讨论】:

      猜你喜欢
      • 2018-09-30
      • 2010-09-19
      • 1970-01-01
      • 2014-09-26
      • 1970-01-01
      • 2017-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多