Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize docstring color for Python in VSCode's default theme?

Could some one explain to me please how to customize docstring color for Python in VSCode's default theme? I want to do it thru User Settings because want to be able to save my config file.

I tried to use "editor.tokenColorCustomizations": {} but it affects all strings.

like image 209
Andrey Marchenko Avatar asked Oct 11 '17 13:10

Andrey Marchenko


2 Answers

Adding to Leonard's answer, if you want to change the triple quotes and escapes too, use the below:

    "editor.tokenColorCustomizations": {
        "textMateRules": [
            {           
                "scope": [
                    "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": "#aab5da" //change to your preference
                }       
            }
        ]
    },

Also, I had a hard time finding the user settings file in json format. You can find that by:

CTRL + SHIFT + P > User Settings > On the open tab level extreme right hand side > Open Settings (JSON) icon (Hover to know which icon)

like image 135
Yashash Gaurav Avatar answered Sep 20 '22 14:09

Yashash Gaurav


Add this to your setting file:

<!-- language: json -->
"editor.tokenColorCustomizations": {
        "textMateRules": [
            {
                "scope":"string.quoted.docstring.multi.python",
                "settings": {
                    "foreground": "#69676c" //change to your preference
                }
            }
        ]
    }

additional info: for finding out the scope of other element, you use the command Developer: Inspect TM Scopes , as described here https://github.com/Microsoft/vscode/pull/29393

more detail: https://code.visualstudio.com/docs/getstarted/themes#_customize-a-color-theme

like image 33
Leonard AB Avatar answered Sep 18 '22 14:09

Leonard AB