read

I love the Dark+ Default Theme for vscode, but when programming in Python I always thought the class instance references (aka self) was too bright, which made the core in the class harder to read.

Before: Dark+ Default Theme, with self in light blue

After: Customizing%20vscode%20themes%

It's pretty easy to customize any attribute in Visual Studio Code — you just need to know which token scope to use. With the cursor over the keyword, use Command Palette (CTRL-SHIFT-P) and select "Developer: Inspect Editor Tokens and Scopes" (official documentation).

The scope for self will show something like this:

Scope for self class instance reference

We're interested in "variable.language.special.self.python". With the knowledge of your scope, open settings.json (CTRL+Comma), and add the following snippet:

"editor.tokenColorCustomizations": {
        "textMateRules": [
            {
                "scope": "variable.language.special.self.python",
                "settings": {
                    "foreground": "#666666"
                }
            }
        ]
    }

UPDATE Jan/2021: the latest version of PyLance language server (v2020.12.2) seems to cause problems with TextMate rules, and it stopped working after the update. I fixed by changing to "scope": variable.parameter.function.language.special.self.python".


Blog Logo

Gui Ambros

Maker, engineer, ad:tech veteran. Incurable optimist. I was there when the web was born. Opinions here are my own. @GuiAmbros


Published

Image

wrgms.com

/dev/random rants about technology, electronics, startups.

Back to Overview