I use Sublime text
. Now I am trying Atom
. When I save any file in sublime text it does not include any trailing blank line. But saving any file in Atom
leaves a trailing blank line. How do I force Atom
not to leave trailing white spaces?

- 3,862
- 4
- 28
- 38
-
3Atom sticks to POSIX definition of a line by default: `"A sequence of zero or more non-
characters plus a terminating – sepehr Jul 12 '15 at 19:34character."` — https://stackoverflow.com/questions/729692/
4 Answers
Under your Atom Preferences
go to Packages
tab and search for whitespace
. Click on the whitespace
package and uncheck Ensure Single Trailing Newline
option

- 3,576
- 2
- 13
- 24
-
31I think its even better if we unckeck "Ignore whitespace On current line". This will remove the trailing whitespace of current line at the time when file is saved. – Gagan Jul 15 '16 at 11:00
-
Could this message get any more cryptic? Lol - I'm just over-joyed to have Atom mangle a long file's diff because another dev left some trailing spaces only to find that it is not possible to find this setting by name. Few.. Anyone notice that the name changed from Package to Settings? – jcalfee314 Jul 27 '17 at 18:49
-
6Maybe this is a new setting, but there is a `Remove Trailing Whitespace` checkbox at the bottom of the `settings` section. Unchecking it preserves all trailing whitespaces. – bluecollarcoder Aug 16 '17 at 00:10
-
On global level this can be changed using settings
in Whitespace
package, but if you want to disable it for a specific language you have to use syntax-scoped properties in your config.cson.
'.text.html.php': # php overrides
whitespace:
ensureSingleTrailingNewline: false
removeTrailingWhitespace: false
'.source.ruby': # ruby overrides
whitespace:
ensureSingleTrailingNewline: false
removeTrailingWhitespace: false
To see the scope of language go to Packages
tab and search for your language.
Click on the settings of the language package and you can see the scope:

- 4,532
- 2
- 36
- 61
-
1Your answer is even more detailed than the official docs at https://github.com/atom/whitespace, thanks for taking the time to put this up! :-) I would love to configure atom this way, but I can't get it to work, atom keeps turning two trailing newlines into a single one in my jinja2 files. Scope is `.text.html.jinja`, config matches yours, but doesn't work. Global it is then :-( – ssc Feb 09 '18 at 22:53
-
The image showing how to find the scope was particularly useful. I've since also found the scopes listed in the grammar selector (by default to the right of the line endings, line number and encoding at the bottom of the window, or with the default shortcut `ctrl+shift+L`). – Steve Mar 29 '19 at 14:40
Go to packages and find "whitespace", go to it's settings and uncheck the last checkbox.

- 876
- 8
- 23

- 111
- 1
- 6
To add to Dan Moldavan's answer.
I experienced this issue when working on a Rails Application.
I added a .editorconfig
file with the following properties:
# editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
And I added a .gitattributes
file with the following properties:
# Enforce Unix newlines
* text=auto eol=lf
And then my Atom Editor threw a problem:
1 problem affecting .gitattributes
whitespace: It is possible that the "whitespace"-package prevents the following properties from working reliably: insert_final_newline, trim_trailing_whitespace. You may try reconfiguring or disabling the "whitespace"-package to solve regarding issues.
Here's how I fixed it:
- Open your Atom Editor
- Go to Edit > Preferences > Packages
- Type in whitespace
- Click on the package that shows up
- Untick the following:
- Ensure Single Trailing Newline
- Ignore Whitespace On Current Line
- Leave Ignore Whitespace Only Lines unticked
Save and close the settings.
That's all.
I hope this helps

- 24,334
- 12
- 145
- 143
-
Do you have any idea how hard it is to read your screenshot? Us a dark theme in your own work if you must, but a light theme makes a much more readable image. – Manngo Apr 05 '22 at 07:48