skip to Main Content

I’m using VS Code for Python on a Mac. The syntax highlighting is very buggy for me. With the dark modern theme, I see:

Image of the problem (example code)

While class names, built-in functions and function names (when defining the functions are colored, most of the other stuff is simply white.

Other themes have the same problem. What is wrong, and how do I fix it?

2

Answers


  1. If you already have the Python extension installed, and are using the Default Modern theme (which supports this colorization), then perhaps you’ve disabled "semantic token color customizations" (editor.semanticTokenColorCustomizations).

    When my settings.json contains this:

    "editor.semanticTokenColorCustomizations": {
        "enabled": false
    },
    

    My code looks like this:

    Image of Python code in VS Code, with semantic token color customizations disabled

    When I remove this setting from my settings.json, the colors are returned to normal:

    Image of Python code in VS Code, with semantic token color customizations enabled

    Some other settings to check are:

    • Token color customizations (editor.tokenColorCustomizations)
    • Color customizations (workbench.colorCustomizations)
    • Your color theme – Dark (Visual Studio) looks almost identical, but doesn’t have semantic token color customizations.
    Login or Signup to reply.
  2. Please fallow this tutorial. It will solve most of your issues, show you how to work with virtual environments and configure extensions.

    TLDR – download python extension and everything will work out of the box. Other useful extensions are ruff and black:

    1. Python – most of intellisense and lang support.
    2. Black -formatter
    3. Ruff – linter with superpowers. Can also sort imports, format code

    As alternative you could also try pyCharm community edition – it’s free tool specifically created for working with python which works out of the box with 0 configuration.

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