Home > OS >  Why the colors of comments and class/function descriptor are the same in VS Code?
Why the colors of comments and class/function descriptor are the same in VS Code?

Time:06-11

I am using the Predawn color theme in VS Code. I use two different servers to work on my codes. In one of them, the color of comments written by """ """ in python is light green and the one written by # is gray, which is exactly what I want.

enter image description here

However, in another server, the colors of both types are gray.

enter image description here

I couldn't find where in the setting to fix it and differentiate these two comments. (I use the remote to connect those servers, so the VS Code is the same for both)

CodePudding user response:

If you go to your settings.json, you can change the color of the docstring comments using

"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope":"string.quoted.docstring.multi.python",
            "settings": {
                "foreground": "#00ff00" // change this
            }
        }
    ]
},

You can also change the color of regular comments by using

"editor.tokenColorCustomizations": {
    "comments": "#ff0000"
},

Result:

enter image description here

CodePudding user response:

I added this code to settings.json (can be found after pressing Ctrl Shift p) to solve the problem:

"editor.tokenColorCustomizations": {
  "textMateRules": [
      {           
          "scope": [
              "string.quoted.multi.python",
              "string.quoted.double.block.python",
              "string.quoted.triple",
              "string.quoted.docstring.multi.python",
              "string.quoted.docstring.multi.python punctuation.definition.string.begin.python",
              "string.quoted.docstring.multi.python punctuation.definition.string.end.python",
              "string.quoted.docstring.multi.python constant.character.escape.python"
          ],          
          "settings": {
              "foreground": "#BDDCDC" //change to your preference
          }       
      }
  ]
  },    

The most important scope for me was "string.quoted.double.block.python".

  • Related