简体   繁体   中英

VS Code editor color customisation for Python imported module names

I have been trying to change the text foreground colour of imported modules in Python files without any success. I am using Monokai Dimmed color theme in VS Code. Everything is ok, except for the Red foreground color of imported modules.

In the example below, can I change the text color of 'json', 'pandas' and 'pd'? Currently, they all appear in red, which hurst my eyes!

import json

import pandas as pd

I tried configuring settings.json:

   "editor.tokenColorCustomizations" : {

        "types": "#17851d",
        "[Monokai Dimmed]": {
            "textMateRules": [
                {
                  "scope": "????",   // I tried several scope, but none worked.
                  "settings": {
                    "foreground": "#FFFF00"    // Trying to change to yellow color
                  }
                }
              ]
        }
    }

Many thanks

The scope is "entity.name.namespace". Use "Developer: Inspect Editor and Token Scopes" in command palette. Then click on the text you want to find the scope for and it will show up.

"editor.tokenColorCustomizations": {
    "[Monokai Dimmed]": {
        "textMateRules": [{
            "scope": "entity.name.namespace",
            "settings": {
                "foreground": "#59be97"
            }
        }]
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM