5

I added this code to my setting.json

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

But It doesn't change the color for slashes as you can see the below screenshot.
It remains still grayed.

How can I change the whole comment color contains slashes?

enter image description here

fabio.sang
  • 835
  • 8
  • 26
AutumnSky
  • 394
  • 2
  • 14

3 Answers3

2

The comments definition (// or # for other languages) can be customized with the punctuation.definition.comment scope in the textMateRules array.

Example:

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

You can see the scopes of all the command Inspect TM Scopes in the command palette.

fabio.sang
  • 835
  • 8
  • 26
2

It looks like the comment punctuation colorCustomization may be corrected - that is, the punctuation like // may be included in the comment scope in the October 2018 release. It is an open issue but was added to the October 2019 milestone, see https://github.com/microsoft/vscode/milestone/102.

So that the comment punctuation would no longer need to be separately colored.

It is fixed in the Insider's Build as of October 25, 2019 so that

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

will color the comment body and punctuation/marker as well.

Mark
  • 143,421
  • 24
  • 428
  • 436
2

I've found this same answer in several places, but for whatever reason, it just wasn't working for me with any of the Material Theme * themes. No matter what I did, the // in JS and first # in Ruby/Shell wouldn't change colors.

enter image description here

To get around this, I had to use the Community version of the Material Theme * themes: e.g. "workbench.colorTheme": "Community Material Theme Darker High Contrast".

Screenshot with fix

Hope this is helpful for anyone else encountering this issue!

Scott Schupbach
  • 1,284
  • 9
  • 21
  • Agreed, there is definitely something in the non-community Matherial Theme (v4.16.0) which overrides these scopes. Only language specific scope worked (ie. punctuation.definition.comment.sql) to specify the color of comment opening/closure. Switching to Community edition works perfectly with generic scopes for comments. Thanks. – Honza Apr 28 '22 at 14:55