在VS Code中覆盖默认语法着色

问题描述 投票:0回答:1

我正在尝试覆盖VS Code中的默认语法颜色。特别要代替默认主题“ Light(Visual Studio)”中的#a31515(红色)颜色,我要查看#036A07(绿色)颜色。

为此,在用户设置editor.tokenColorCustomizations文件的settings.json中,我更改了此默认值:

"editor.tokenColorCustomizations": null

至:

"editor.tokenColorCustomizations": {
            "markup.deleted": "#036A07",
            "meta.preprocessor.string": "#036A07",
            "string": "#036A07",
            "entity.name.operator.custom-literal.string": "#036A07",
            "meta.embedded.assembly": "#036A07"
        }

我保存了settings.json文件并重新启动了VS代码,但是代码突出显示没有看到任何变化(与以前一样略带红色):

enter image description here

问题:我的代码有什么问题,正确的代码是什么?

visual-studio-code vscode-settings
1个回答
0
投票

您必须像这样添加每个范围的定义。

  "editor.tokenColorCustomizations": {
     "textMateRules": [
        {
          "name": "Deleted",
          "scope": "markup.deleted",
          "settings": {
            "fontStyle": "italic",
            "foreground": "#036A07"
          }
        },
        {
          "name": "Strings",
          "scope": "meta.preprocessor.string",
          "settings": {
            "fontStyle": "italic"
          }
        },
        {
          "name": "ThisIsJustANameForReference",
          //You can use coma separated scopes to group them into one
          "scope": "entity.name.operator.custom-literal.string, meta.embedded.assembly",
          "settings": {
            "foreground": "#036A07"
          }
        },
      ]
  },
© www.soinside.com 2019 - 2024. All rights reserved.