Automatically add newline on save in PyCharm? Automatically add newline on save in PyCharm? python python

Automatically add newline on save in PyCharm?


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)


Newer PyCharm I believe (2020+):

enter image description here


What I usually do is I create a macro to do three things:

  • Reformat code
  • Organise imports
  • Save all files

This will, indeed, add a newline at the end of each file.Then I rebind the Save all shortcut (Cmd+S on Mac) to this macro.

You can read more about macros here. I also recommend using Navigate to Action to find actions you forget the hotkeys for.