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:
After:
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:
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"
.