Coder Perfect

In PyCharm, how do I set the maximum line length?


I’m using PyCharm on Windows and want to adjust the settings to limit the maximum line length to 79 characters instead of the 120 characters that it now allows.

In PyCharm, where can I alter the maximum number of characters per line?

Asked by Ansuman Bebarta

Solution #1

A screenshot of my Pycharm is shown below. The following path has the necessary settings: Editor -> Code Style -> File -> Settings -> Editor -> Code Style -> Right margin in general (columns)

Answered by Alex G.P.

Solution #2

For PyCharm 2018.1 on Mac, follow these steps:

Editor -> Code Style: Preferences (+,,,,,,,,,,,,,,,,,,,,,,,,,,

For PyCharm 2018.3 on Windows, follow these steps:

Editor -> Code Style: (Ctrl+Alt+S), then File -> Settings (Ctrl+Alt+S).

Set Hard wrap at 80 to follow PEP-8.

Answered by lmiguelvargasf

Solution #3

For PyCharm 4

Editor >> Editor >> Editor >> Editor >> Editor >> Editor >> Editor >> Editor >> Editor >> Editor Style of code: right margin (columns)

suggestion: Look at the other choices in that tab; they’re quite useful.

Answered by Marco Sanchez

Solution #4

For HTML, you may even create a separate right margin. Under the following path:

Right margin >> File >> Settings >> Editor >> Code Style >> HTML >> Other Tab >> (columns)

This is incredibly beneficial because HTML and JS are frequently much longer on a single line than Python.

Answered by andy

Solution #5

When doing a code reformat, there is an additional option to check under editor->code style->python: ensure right margin is not exceeded for anyone who is having problems, even myself if I reload my workstation. The reformat would begin after this option was chosen.

Answered by Steve Stacha

Post is based on