atom: automatically removing trailing spaces

3

I've recently tried atom and have one thing against it: it tries to do the smart thing and removes all trailing spaces when I save a file - without telling me. Some editor does this but this is bad when it comes to change control. Not sure why the programmers would make this the default behavior and I couldn't find an option to disable it.

Is there a way to disable this in Atom?

lang2

Posted 2015-08-23T01:02:55.023

Reputation: 1 830

For the record: you don't want this whitespace commit noise to show up day to day in your commits. If you're working in a team it's a good idea to 1) remove all trailing white space in one fell swoop 2) let everybody configure their editor to auto-remove trailing whitespace. And, we shall have peace. – Niels Bom – 2015-09-23T14:50:05.657

Of course all trailing spaces should be gone in the code. But I don't think it's a job for the editor. Not by default anyway - nobody touches my code without going through me. – lang2 – 2015-09-23T15:42:52.377

Seems not everyone agrees with your last sentiment: https://golang.org/cmd/gofmt/ :-)

– Niels Bom – 2015-09-25T10:24:23.413

It's perfectly OK to have an auto formatting tool that does a good job. And I like the way that everybody's code look the same. But not by default without telling. Maybe I'm just old fashioned. :) – lang2 – 2015-09-25T15:56:06.687

Answers

11

Yep!. It's not in the core 'Settings' pane, but rather part of one of the core packages. Open up the settings view (Mac: Atom > Preferences), select 'Packages' from the list on the left, and find the whitespace package (type "whitespace" in the search box under Installed Packages:

Searching for the whitespace package

There's a checkbox to disable the auto-removal of trailing spaces under that package's settings:

Whitespace package settings

Doches

Posted 2015-08-23T01:02:55.023

Reputation: 226

0

All I can say is thank god for git add -p otherwise I would have accidentally included several hundred modified lines in several files in my first few commits after using atom. Still took me forever to filter all those changes out. Bad choice by atom but they are sticking with it I guess.

Reed Hedges

Posted 2015-08-23T01:02:55.023

Reputation: 173

I found some ways to get a patch with non-whitespace-only changes here: https://stackoverflow.com/questions/3515597/add-only-non-whitespace-changes which saved me some tedious work undoing atom's helful work.

– Reed Hedges – 2017-03-23T22:26:56.253