• [PyCharm IDE]
Skip to end of metadata
Go to start of metadata

Syntax highlighting

When you type your code in the editor, PyCharm analyses it on-the-fly. The IDE smartly discerns keywords, values, strings, comments, etc. The way PyCharm highlights these symbols, is defined in the Colors and Fonts settings (Ctrl+Alt+SIDE Settings→Editor→Color and Fonts).

You can select a language, for example, Python, and change to your taste the way it renders the various language elements. Note, however, that PyCharm comes with a set of read-only color schemes, which you cannot modify - you have to create a copy of some color scheme first, and only after that make your changes:

All changes are reflected in the Preview pane. When you feel happy with the new code style, you can apply changes and close the Settings dialog.

Refer to the page Configuring Colors and Fonts for details.

Marking occurrences

Let's go on with the code. If you want to find out how many times a certain symbol has been used, place the caret at one of the occurrences - the other occurrences of this symbol become highlighted. Moreover, the occurrences stripes appear in the right gutter. If you hover your mouse pointer over such a stripe, PyCharm will show the description of the corresponding occurrence at the tooltip:

Error indication

If PyCharm, in course of code analysis, encounters any errors, they are immedeately reported in the following ways:

  • The erroneous code is underlined with the red curvy line. If you hover your mouse pointer over this curvy line, the detailed information about the error appears at the tooltip.
  • The file name in the editor tab is also underlined with the red curvy line. Moreover, the file in the Project tool window, and even the parent directory are also underlined.

  • An error marker appears in the right gutter. When you hover your mouse pointer over an error marker, a balloon with the detailed information about the error appears:

The error markers can be also used as the means of navigation. When you click an error marker, the line that contains the error gets the focus, and the caret rests at the erroneous code.

  • The box on top of the right gutter shows aggregated information about the entire file and is color-coded: green means that everything is OK, yellow means some problems and warnings, and red means serious errors.

Needless to say that error highlighting is also configurable - in the General page of the colors and fonts settings (Ctrl+Alt+SIDE Settings→Editor→Colors and Fonts→General):

Meet Hector

Look at the guy at the very bottom of the PyCharm window:

His name is Hector-the-Inspector, and he is responsible for inspecting code. If you click Hector, you will see the pop-up window with the Highlighting level slider:

If you are sure of yourself, move the slider to the left, to the positions Syntax or None. In the position Syntax, only syntax highlighting is provided, and Hector turns half-face. In the position None, neither syntax highlighting, nor inspection is performed - your editing becomes much faster, but less comfortable; Hector fades.

This way you can change inspection behavior for the current file only. If you open a different file for editing, it will have a different inspection behavior, and Hector will look differently.

If you want to change inspection settings, click the link Configure inspections. To learn how to configure inspections, refer to the section Code Inspections and to the code inspection tutorial.

Other topics of this tutorial

Your Rating: Results: PatheticBadOKGoodOutstanding! 28 rates
  • No labels