【问题标题】:How do I add a background color (highlight) class names in VS code如何在 VS 代码中添加背景颜色(突出显示)类名
【发布时间】:2021-12-26 09:50:14
【问题描述】:

我想通过突出显示类名来使 HTML 文件在 VS Code Editor 上更具可读性,如下所示。

example

我已经走到这一步了,但不知道接下来要在 *json 文件中添加什么代码。

"editor.tokenColorCustomizations": {
"textMateRules": [
  {
    "scope": "entity.name.selector",
    "settings": {
      "foreground": "#ff00ff",
      "fontStyle": "bold",
      
    }
  }
]

【问题讨论】:

  • 如果您只想更改班级颜色,我不知道。但是你可以尝试其他的 vscode 主题。你可以看看article for good themes。对于 windows CTRL + K + T 对于 mac cmd + K + T
  • 您不能通过 tokenColorCustomizations 设置语法的背景颜色样式 - 只有您正在使用的前景和字体样式。

标签: html visual-studio-code


【解决方案1】:

您可以使用扩展名Highlight

将此添加到您的 settings.json(全局或工作区)

"highlight.regexes": {
  "( class=)(\"[^\"<>]*\")": {
    "regexFlags": "g",
    "filterLanguageRegex": "html",
    "decorations": [ 
      {  },
      { "backgroundColor": "#f0000040" }
    ]
  }
}

【讨论】:

  • 当我在“工作区”选项卡下编辑 *json 文件时它可以工作,但它在“用户”选项卡下不起作用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-04
  • 1970-01-01
  • 2014-01-15
  • 1970-01-01
  • 1970-01-01
  • 2013-01-09
相关资源
最近更新 更多