在 VSCode 中自定义“反引号”内文本的颜色

Nik*_*kos 3 color-scheme syntax-highlighting editor visual-studio-code

我能找到的在 Visual Studio Code 中处理自定义着色的唯一选项是:

"editor.tokenColorCustomizations": {
    "[Atom One Dark]": {
        "comments": "#FF0000" // only 6 color-customizable
    },
    "workbench.colorCustomizations": {
        "statusBar.background": "#666666",
        "panel.background": "#555555",
        "sideBar.background": "#444444"
    },
},
Run Code Online (Sandbox Code Playgroud)

有没有办法为这些类型的东西设置自定义颜色?其中一个用于注释,用于字符串(在 内部"string")。我相信使用正则表达式的其他东西应该有类似的东西。提前致谢。

Mar*_*ark 8

搜索tokenColorCustomizationsandtextMateRules你会发现你可以做这样的事情(参见colorizing with textmate):

"editor.tokenColorCustomizations": {

    "textMateRules": [
      {
            // works for a language that recognizes backticks as string templates
        "scope": "string.template",
        "settings": {
          "foreground": "#FF0000"
        }
      },
      {
       "scope": "punctuation.definition.template-expression.begin, punctuation.definition.template-expression.end",
       "settings": {
         "foreground": "#F0F"
       }
      },
    ]
}
Run Code Online (Sandbox Code Playgroud)

使用Inspect TM Scopes...命令面板中的命令。因此,我使用该命令在模板文字内单击并获取范围string.template.js.jsx。但这并没有改变 ${someVar} 所以我检查了该范围并看到了 variable.other.readwrite.js.jsx附加的范围参数 - 仍在努力将这种变量与其他变量隔离。

string.template编辑:如果语言将反引号视为字符串模板,则应该仅使用 来处理更多文件类型。

您还可以更改fontStyle设置内的内容。这里有一些关于使用该TM Scopes命令的答案。