Automatically add newline on save in PyCharm?

Markus Meskanen picture Markus Meskanen · Mar 16, 2016 · Viewed 14.5k times · Source

PyCharm 5 complains of a missing newline at the end of the file:

PEP 8: No newline at end of file

How do I tell PyCharm to add the newline (if missing) automatically whenever I save a file?

Answer

dcoles picture dcoles · May 16, 2016

This can be enabled in the Editor > General settings:

From the File menu open the Settings and select Editor > General. Under the Other section in the right-hand pane, check the Ensure an empty line at the end of a file on Save setting.

Ensure an empty line at the end of a file on Save (PyCharm PE 2020.1.3)