Roux
Roux

Reputation: 69

I can't change variable colors One Dark Pro Visual Studio Code for Python

I'm having an issue regarding Visual Studio Code OneDark Pro theme. I would like to change the color of variables (only variables I declare, not method calls, etc. but when I try to do this using

    "editor.tokenColorCustomizations": {
        "textMateRules": [
          {
            "scope": "source.python",
            "settings": {
              "foreground": "#E06C75"
            }
          }
        ]
      }

I get this (I wrote a code sample to illustrate what is happening):

enter image description here

As you can see, colons are in red, every variables even the "for i in..." and the full "os.system.getcwd()" are in red.

I only want the variables I declare to be in red. How can I do that ? Thank you in advance!

Upvotes: 0

Views: 6627

Answers (1)

Steven-MSFT
Steven-MSFT

Reputation: 8431

You can modify the editor color in VSCode with Syntax Highlighting like this:

 "editor.tokenColorCustomizations": {
        "variables": "#c3e01f"
      },

Or the Semantic Highlighting like this:

  "editor.semanticTokenColorCustomizations": {
    "[The Theme Name]": {
      "rules": {
        "variable.declaration": "#c3e01f"
      }
  }
},

If you don't know the scope of the object which you want to customize, you can use the built-in tool in VSCode: Developer: Inspect Editor Tokens and Scopes(Command Palette).

And I think this article and this one can help you understand the color customization in the VSCode.

Upvotes: 5

Related Questions