IDLE won't highlight my syntax
Asked Answered
F

4

7

Using IDLE and Python version 2.7.3. Only when I start a new file it highlights for a few lines and then just stops after I press F5. So all my text becomes plain black.

If there are equally good/better command line and editor combinations out there, you may always suggest them.

Footcandle answered 14/4, 2012 at 18:56 Comment(1)
I have the same problem both under Windows 7 AND MacOSX, on different computers! Baffling really...Scathe
S
18

This happened to me too. Save it as .py (manually type .py in the document name), and the highlighting will come back.

Sulfate answered 11/7, 2013 at 19:27 Comment(2)
I also experienced the same thing with 2.7.9 and this was the correct answer for me.Sulphurize
Noted and changed (albeit 3 years later...)Footcandle
Z
7

Check the key binding for the toggle-auto-coloring option under Options -> Configure IDLE -> Keys -> Custom Key Bindings. The default is Ctrl+/. This should allow you to turn the syntax highlighting back on. (You can't toggle it off though, heh)

Works for me on both IDLE 2.7 and IDLE 3.3.3.

Zakarias answered 30/3, 2014 at 16:20 Comment(1)
@sterling Feel free to edit answers to add useful info.Fearful
O
6

I usually have to save the file as .py before IDLE will do any syntax highlighting at all. Not sure why it would highlight for a few and then stop though. I've never had that happen.

Oystercatcher answered 14/4, 2012 at 19:0 Comment(0)
L
2

Is this under Windows? Is it possible your file association for Python files have possibly changed? (not quite sure why/how this could happen, but perhaps something worth checking)

Lilli answered 14/4, 2012 at 20:42 Comment(4)
Well it doesn't have any association at all now. Which application should I use in my C:\Pyhon27\ folder?Footcandle
@PatronBernard can you try python.exe - that's what I have with Windows 7 - it's a long shot, but perhaps it will help. It is odd, because most tools will just look at the .py file extension to activate the syntax highlighting.Lilli
@PatronBernard Here are some links for alternative Python editors: wiki.python.org/moin/PythonEditors and this #127253 Hope this helpsLilli
I am now using PyDev and Eclipse. Works like a charm!Footcandle

© 2022 - 2024 — McMap. All rights reserved.