VS Code:如何更改 XML 属性的颜色

ymu*_*ruc 2 xml color-scheme token visual-studio-code

如何在 Visual Studio Code 中更改XML 属性的颜色?

例如,如何为identifiant以下属性选择另一种颜色: xml样本

以下是当前的颜色主题设置:

"editor.tokenColorCustomizations": {
    "[Solarized Dark]": {
        "keywords": "#f00"
    },
    "functions": "#f5896e",
    "numbers": "#dfd51b",
    "keywords": "#215c21",
    "strings": "#67f7e3",
    "variables": "#22FF88",
    "comments": "#332244"
}
Run Code Online (Sandbox Code Playgroud)

或者更直观

色彩主题

换句话说:是否有专门适用于“XML 属性”的标记?

Mar*_*ark 5

是的,使用Scopes检查器 - 调用命令Developer: Inspect Editor Tokens and Scopes

您将看到 xml 属性名称具有范围entity.other.attribute-name.localname.xml。因此,您可以将此 textmate 规则添加到您的editor.tokenColorCustomizations设置中:

  "editor.tokenColorCustomizations": {

        "textMateRules": [
          {
            "scope": "entity.other.attribute-name.localname.xml",
            "settings": {
              "foreground": "#f3873f",
              "fontStyle": "italic"
            }
          },
        ]
  }
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请参阅textmate 范围。