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:
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
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:My code looks like this:
When I remove this setting from my
settings.json
, the colors are returned to normal:Some other settings to check are:
editor.tokenColorCustomizations
)workbench.colorCustomizations
)Dark (Visual Studio)
looks almost identical, but doesn’t have semantic token color customizations.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:
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.