5

how can I change the color of the characters that come before and after a comment in vs code. Im Talking about or /* */ or # characters. I know how to change the comment color

How do I change color of comments in visual studio code?

but couldn’t find anything regarding the „framing“ characters.

Gama11
  • 31,714
  • 9
  • 78
  • 100
aerioeus
  • 1,348
  • 1
  • 16
  • 41
  • I don't believe this is achievable. Why is this necessary? – emsimpson92 Sep 04 '18 at 22:33
  • I just want don’t like it with different colors. Why shouldn’t it be achievable. There must be a setting to do this like some scope settings. I just don’t know where to look... – aerioeus Sep 04 '18 at 22:36
  • That's a pretty specific request and not really a feature that many people would even care about. I'd be surprised if something like this exists. – emsimpson92 Sep 04 '18 at 22:38
  • @emsimpson92 I don’t know what such a comment is aiming at. We ask questions here to seek a solution it’s not for you to judge if that is seemly or not, if you don’t know the answer, just stay calm but pls refrain from trolling... – aerioeus Sep 05 '18 at 06:22
  • I wasn't trolling. I just said I'd be surprised if it exists. – emsimpson92 Sep 05 '18 at 17:41
  • ok, then sorry for my misinterpretation; as you see it fortunatly does, I'm already diving into the whole `textMateRules`thing... – aerioeus Sep 06 '18 at 13:32

2 Answers2

5

You can do this rather simply. Use "Inspect TM Scopes" in the command palette to inspect those characters. It will give a different scope for each language, something like :

punctuation.definition.comment.js

for javascript comments. Now you can use that in your user settings like so:

"editor.tokenColorCustomizations": {
    "textMateRules": [

      {
        "scope": "punctuation.definition.comment.js",
        "settings": {
          "foreground": "#f00",
        }
      }
   ]
}

You will obviously have a different but similar scope for other languages.


And see the short answer added to How to change VisualStudioCode comment color with it's slashes? about possible plans to fix this in the October, 2019 release. So the punctuation would not have to be independently colored. [It is now fixed in the Insider's Build.]

Mark
  • 143,421
  • 24
  • 428
  • 436
  • 1
    great, thanks a lot, worked like a charm, you can simply add the ending of the language you need to apply it to other languages' comments... ```"editor.tokenColorCustomizations": { "[Monokai Classic]": { "comments": "#60d01a", "strings": "#ece233", "selector": "#60d01a" }, "textMateRules": [ { "scope": "punctuation.definition.comment.yaml", "settings": { "foreground": "#60d01a", } } ] ``` – aerioeus Sep 05 '18 at 10:41
  • do you know, how one could set this up for multiple languages, does the command support lists/arrays? – aerioeus Sep 05 '18 at 10:45
  • never mind, I found it out, the only one that doesn't seem to work is the extension `css`, any idea, what the proper extension here for css could be? – aerioeus Sep 05 '18 at 11:00
  • I see these scopes for css comments using the above method: punctuation.definition.comment.end.css and punctuation.definition.comment.begin.css – Mark Sep 05 '18 at 11:05
  • You do NOT have to specifically define each language. You can leave off the language extension from the scope like so: `"scope": "punctuation.definition.comment",` – Wade Mar 27 '19 at 00:36
2

You can use the following to fully define the comment colors globally. You do not have to do one for each language!

settings.json

"editor.tokenColorCustomizations": {
    "comments": "#636363",
    "textMateRules": [{
        "scope": "punctuation.definition.comment",
        "settings": {
            "foreground": "#636363",
        }
    }]
},

Notice I omitted the language, ie: .php, from the end of the scope line.

This will do both the beginning/end of the comment block, and the comment itself. I was baffled when I changed my comment colors and the /** and */ where not changed. This solved it and made the comments all one color.

Wade
  • 3,757
  • 2
  • 32
  • 51