【问题标题】:Is it possible to have different color and font settings for comments when they start with # or ## in VS Code?在 VS Code 中以 # 或 ## 开头的注释是否可以有不同的颜色和字体设置?
【发布时间】:2021-03-25 00:37:32
【问题描述】:

我想用 cmets 更好地构建我的代码,但我想为 cmets 设置不同的类别,描述下面的代码的类别,以及对我来说更个性化的类别,包括我以后想要考虑的内容,等等。

例如,对于以# 开头的其他以## 开头的 cmets,是否可以有不同的颜色和字体设置?

【问题讨论】:

  • 如果他们有不同的 TextMate 范围,你可以使用颜色自定义,如果没有,你可以使用扩展 Highlight

标签: python visual-studio-code colors comments settings


【解决方案1】:

使用 Highlight 扩展名,将其放入您的 settings.json:

  "highlight.regexes": {

    "(##\\s*)(.*)|(#\\s*)(.*)": {
      "filterLanguageRegex": "python",
      "regexFlags": "gm",
      "decorations": [
        {"color": "yellow"},
        {
          "color": "yellow",
          "backgroundColor": "#f005",
          "fontWeight": "bold",
          "fontStyle": "italic"
        },
        {"color": "orange"},
        {
          "color": "orange"
        }
      ]
    }
  }

您可以使用此扩展程序进行很多样式设置,请参阅https://code.visualstudio.com/api/references/vscode-api#DecorationRenderOptions

【讨论】:

    猜你喜欢
    • 2012-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-09
    相关资源
    最近更新 更多