Stop Atom from removing empty whitespace lines when saving?


#1

Whenever I am using Atom as a text editor, no matter if I have it language grammar set to HTML, CSS, js, or even plain text… I tend to like to slip 10+ lines at the end of a document, so that the last line of code isn’t at the very bottom, almost off the page. However, whenever I perform a [ Cmd + S ] if I’m on a Mac or [ Ctrl + S ] on my work PC, the extra lines that I’d like to keep are stripped out, and the whole document snaps to the bottom line.

At first I thought this was something that the Atom Beautify package might be doing, but it happens whether I’ve ‘beautified’ a file already or not.

I know that an easy workaround would be to add a blank multiline empty comment at the bottom of any document I’m working on. But I am hoping there is a less clunky option. Anybody know how to make Atom give me some space? :wink:


#2

The less clunky option is to control the behavior directly with the whitespace package (Settings -> Packages, click on the button for whitespace under Core Packages).


#3

I really thought that would be it… but it didn’t work. I went to the whitespace packages settings, unchecked the “Remove Training Whitespace” checkbox, and closed settings. I even reopened them to make sure the change was saved.

Then I tested it to see if my empty lines at the end of a document were vanish when I saved, and they still did. I even saved all files, closed out of everything, exited Atom, and restarted it. I went to the whitespace setting to make sure it was still unchecked, it was, and I tested again. Still strips away all empty lines at the end of a document.

Bummer.


#4

uncheck first setting:

Ensure Single Trailing Newline


#5

It is not exactly an answer to your question, but I think it solves your problem in spirit.

In the editor options there is a checkbox for “Scroll past end”

This will let you scroll your document down so the last line isn’t off the page, even if there are not 10 or so lines of whitespace underneath.