skip to Main Content

I can’t change the color of the module name in VS Code, Python code, the following setting.json code does not work, can you give me some tips to teach me how to change the color of the module name?

"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": "entity.name.module.python",
            "settings": {
                "foreground": "#008000"
            }
        }
    ]
}

For example, my goal is to change the color of the "random" in "import random"

2

Answers


  1. Chosen as BEST ANSWER
    "editor.tokenColorCustomizations": {
        "textMateRules": [
            {
                "scope": "entity.name.namespace",
                "settings": {
                    "foreground": "#008000"
                }
            }
        ]
    }
    

  2. You could use the module semantic token type. Like so:

    "editor.semanticTokenColorCustomizations": {
        // optionally wrap the following in a "[Color Theme Name]": { ... }
        "rules": {
            "module": "#ff0000"
        }
    }
    

    This will apply to all module semantic tokens in any language.

    Or you could use the entity.name.namespace TextMate token scope. Like so:

    "editor.tokenColorCustomizations": {
        // optionally wrap the following in a "[Color Theme Name]": { ... }
        "textMateRules": [{
            "scope": "entity.name.namespace",
            "settings": {
                "foreground": "#FF0000",
            }
        }]
    },
    

    This will apply to all entity.name.namespace TextMate tokens scopes in any language.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search