如何在 Visual Studio Code 中自定义 HTML 属性的颜色?

md *_*mon 7 textmate visual-studio-code

如何在 Visual Studio Code 中自定义 HTML 属性的颜色,例如 class=""、href=""、src=""、style="" 等?

Ste*_*nie 9

打开settings.json文件并添加以下内容:

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

您也可以将主题设置为仅适用于该主题,而不适用于全局。是所有这一切的诀窍。

  • 有没有办法只针对特定属性,例如“class”? (2认同)