In my case, it was just the theme issue. After the latest update, VSCode changed the theme to Dark Modern which is fine, but I wanted to use my existing one so I selected the Dark Theme (but my previous one was actually Dark+).
The difference between the two is the syntax highlighting feature so switching to the Dark+ Theme fixed the syntax highlighting not being enabled.
Answer from Irfan wani on Stack OverflowIn my case, it was just the theme issue. After the latest update, VSCode changed the theme to Dark Modern which is fine, but I wanted to use my existing one so I selected the Dark Theme (but my previous one was actually Dark+).
The difference between the two is the syntax highlighting feature so switching to the Dark+ Theme fixed the syntax highlighting not being enabled.
I also had the same problem for TypeScript React (.tsx) files though in my case it was due to the JavaScript & TypeScript Nightly extension so disabling it fixed my syntax highlighting.
Python syntax highlighting has recently stopped working correctly, even without any extensions enabled.
Is there a way to configure this? I cannot find any good resources on this, other than extensions providing custom syntax highlighting. This is something that is shipped with VSCode out of the box, so I would assume that it can be configured somehow?
A few things I checked:
-
I'm on the latest VSCode version (8/14)
-
No Python extensions are installed (no pylance etc.).
-
Changing color theme does not do anything. I don't even have custom themes.
Here is one example: It thinks that UPDATE (inside a comment) is the start of a new syntax node, and the entire highlighting in the file from there is wrong:
Videos
I've been using both VS Code and Sublime for a while now. I mostly do my python coding in Sublime and I have recently decided to try out VS Code. One issue though.
The syntax highlighting for python is not functioning in the manner I would expect. Here is a .py file opened in both VS Code and Sublime for comparison:
Sublime Text:
https://i.stack.imgur.com/biDjC.png
VS Code:
https://i.stack.imgur.com/r3JVQ.jpg
When comparing the VS Code syntax highlighting to that of Sublime, it appears to only function half correctly.
Tons of stuff that I would expect to receive some form of colored formatting such as function calls, function parameters etc all just appear as white text.
After looking at loads of VS Code python tutorials online, it would definitely seem something is wrong with my setup as everyone else seems to receive function calls/function paramters/etc syntax highlighting.
Troubleshooting progress so far:
I have the VS Code python extension installed.
I've tried uninstalling and reinstalling VS Code.
I've tried uninstalling and reinstalling Python extension.
I've tried installing the magicPython extension.
Ensuring I have both python2 and python3 installed on my machine
Color theme is currently Dark+, however this behavior occurs with all color themes.
Made sure the file ends in .py
I'm running on a Mac, if that's relevant.
Any help would be greatly appreciated. Thank you!
I have two files in directory: main.py and test.py
in test.py i have a function:
def test_function():
print('test')in main.py I'm trying to access said function by importing:
from test import test_function
when I'm running this code everything is working fine but highlighting doesn't work on test.py
Couple days ago everything was working fine. The only thing I changed in my system - uninstalled AnyDesk software from it. I reinstalled Python extension, vs code itself, even python and nothing fixes the issue.
SOLUTION:
Looks like it's a bug in newest version of Pylance extension. I rolled it back to version v2023.3.10 and problem is fixed.
Attached is the image. This is a fresh install of VSCode with Python, Pylance and Jupyter extensions installed. Any reason the syntax highlighting is not working on "number"?
Uninstalling the Python for VSCode extension fixed the issue.
This may be overkill, but I solved this problem on Linux Mint like this:
sudo apt purge code
sudo apt autoremove
rm -fR ~/.config/Code
sudo apt install code
Then I installed the PyLance extension for rich highlighting.
Hi all.
I'm a complete newb on VS Code.
Below is my hello.c program -- as you can see there is no syntax highlighting.
I have only one extension enabled: Microsoft's C/C++ IntelliSense, debugging, and code browsing. v1.14.4
What am I doing wrong?
(Also, F5 does not actually run anything, but I'd like to solve the syntax highlighting first.)
Thanks in advance!
-C
No syntax highlighting Microsoft's C/C++ IntelliSense, debugging, and code browsing. v1.14.4I ran into the same issue and some VS Code themes are not supporting syntax highlighting atleast for me. I tried with Ruby and Python and the theme I was using was Dark(Visual Studio).
Changing to Dark+ (Default Dark) did the trick for me.
Goto Preferences -> Color Themes and choose Dark+(Default Dark) or something similar.
Hope it helps.
Looks like this issue has been bouncing around between maintainers of VSCode, MagicPython, and the Python extension
A quick workaround is to simply override your color theme as instructed here. For example, if you are using Default Dark+ color theme, you can add this to settings.json:
Copy"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "meta.function-call.generic.python",
"settings": {
"foreground": "#DCDCAA"
}
}
]
},
Now callables are highlighted correctly as seen below:
