Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IDLE won't highlight my syntax

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.

like image 241
Jan M. Avatar asked Apr 14 '12 18:04

Jan M.


People also ask

How do I enable syntax highlighting in Python?

You can change the syntax highlighting theme by clicking Options > Configure IDLE and switching to the Highlights tab.

What is syntax highlighting in idle?

Syntax highlighting is an important feature of any IDE that highlights the syntax of the language that you're working in. This helps you visually distinguish between the different Python constructs and the data used in your code. Python IDLE allows you to fully customize the appearance of your Python code.

How do I enable idle in Python?

You can also open IDLE directly from your Python script file. Right click the file, then choose "Edit with IDLE". Rather than going through the "Run..." menu, learn to use F5 (on some systems, Fn + F5) to run your script. It's much quicker.


3 Answers

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

like image 181
user2574063 Avatar answered Oct 12 '22 15:10

user2574063


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.

like image 37
oob Avatar answered Oct 12 '22 15:10

oob


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.

like image 6
Alex Avatar answered Oct 12 '22 15:10

Alex