如何使用斜杠更改 Visual Studio Code 注释颜色?

How to change VisualStudioCode comment color with it's slashes?

我将此代码添加到我的 setting.json

"editor.tokenColorCustomizations": {
    "comments": "#00ff00"
}

但它不会改变斜线的颜色,如下面的屏幕截图所示。
它仍然是灰色的。

如何更改包含斜杠的整个评论颜色?

可以使用 textMateRules 数组中的 punctuation.definition.comment 范围自定义注释定义(// 或 # 对于其他语言)。

示例:

"editor.tokenColorCustomizations": {
  "[Material Theme Darker High Contrast]": { // optional name of a specific theme
    "textMateRules": [
      {
        "scope": "punctuation.definition.comment",
        "settings": {
          "foreground": "#00ff00"
        }
      }
    ]
  }
}

您可以在命令面板中看到所有命令的范围Inspect TM Scopes

评论标点符号 colorCustomization 似乎已更正 - 也就是说,punctuation// 可能包含在 2018 年 10 月版本的 comment 范围内。这是一个未解决的问题,但已添加到 2019 年 10 月的里程碑中,请参阅 https://github.com/microsoft/vscode/milestone/102

评论标点不再需要单独着色

自 2019 年 10 月 25 日起,它已在 Insider's Build 中修复,因此

"editor.tokenColorCustomizations": {
    "comments": "#00ff00"
}

将为评论正文和 punctuation/marker 着色。

我在几个地方找到了同样的答案,但无论出于何种原因,它对我来说都不适用于任何 Material Theme * 主题。无论我做什么,JS 中的 // 和 Ruby/Shell 中的第一个 # 都不会改变颜色。

为了解决这个问题,我不得不使用 Material Theme * 主题的 Community 版本:例如"workbench.colorTheme": "Community Material Theme Darker High Contrast".

希望这对遇到此问题的其他人有所帮助!