Atom text editor remove trailing whitespace on save
Solution 1
Under your Atom Preferences
go to Packages
tab and search for whitespace
. Click on the whitespace
package and uncheck Ensure Single Trailing Newline
option
Solution 2
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:
Solution 3
Go to packages and find "whitespace", go to it's settings and uncheck the last checkbox.
![Nasif Md. Tanjim](https://i.stack.imgur.com/Tx29B.jpg?s=256&g=1)
Nasif Md. Tanjim
I am a software developer. I work in Java related technologies including Android. I also have modest skill in frontend technologies.
Updated on July 25, 2020Comments
-
Nasif Md. Tanjim almost 4 years
I use
Sublime text
. Now I am tryingAtom
. When I save any file in sublime text it does not include any trailing blank line. But saving any file inAtom
leaves a trailing blank line. How do I forceAtom
not to leave trailing white spaces? -
Gagan almost 8 yearsI 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.
-
jcalfee314 almost 7 yearsCould 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?
-
bluecollarcoder almost 7 yearsMaybe this is a new setting, but there is a
Remove Trailing Whitespace
checkbox at the bottom of thesettings
section. Unchecking it preserves all trailing whitespaces. -
ssc over 6 yearsYour answer is even more detailed than the official docs at 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 :-( -
Steve over 5 yearsThe 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
). -
Matt Kleinsmith over 3 yearsFile --> Settings --> Packages
-
Manngo about 2 yearsDo 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.