Syntax highlighting

Published

2022-08-07

What is “syntax highlighting”?

If you’re using an IDE, no doubt you’ve noticed that as you type code in it changes color. This is what’s called “syntax highlighting”, and it’s done automatically by virtually all modern IDEs.

Its purpose is to give visual cues to the programmer and anyone reading the code.

It’s important to understand that the colors applied are not part of the code—they are applied dynamically in the editor window of your IDE, and are not saved as part of your source code files. So this coloring has no significance for Python, but serves only as an aid to those reading the code.

Syntax highlighting helps the reader distinguish between

  • strings
  • numeric literals
  • Python keywords
  • Python built-in functions
  • identifiers (e.g., names)
  • constants
  • comments
  • TODO items
  • etc.

Original author: Clayton Cafiero < [given name] DOT [surname] AT uvm DOT edu >

This material is for free use under either the GNU Free Documentation License or the Creative Commons Attribution-ShareAlike 3.0 United States License (take your pick).