0

I'm currently setting up VS Code for Python development. I'd like to have triple-quoted docstrings highlighted as comments, not as strings, i.e. grey instead of light green in this picture:

enter image description here

I know that I can adjust this in the TextMate rules for this theme, but I can't figure out the right scope for Python docstrings. I thought I would be something like this:

"editor.tokenColorCustomizations": {
    "[Predawn]": {
        "comments": "#777777",
        "textMateRules": [
            {
                "scope": "string.quoted.triple",
                "settings": {
                    "foreground": "#777777"
                }
            }
        ]
    },
}

but that does not have the desired effect, even after restarting the editor. Does anyone know what the right scope is?

gmolau
  • 2,815
  • 1
  • 22
  • 45

2 Answers2

2

Try using this one

"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": "#777777" //change to your preference
          }       
      }
  ]
Hadij
  • 3,661
  • 5
  • 26
  • 48
1

Just to expand on the comments above, the scopes are:

For docstrings: string.quoted.docstring.multi.python for """ ''' (or .single for ' ")

For triple quote strings that are not docstrings: string.quoted.multi.python

The scope string.quoted.triple is not used, even though it appears in settings.json autocomplete.

shadow-light
  • 447
  • 5
  • 7