Atom-beautify removes indentation from empty lines


#1

Hi guys, I searched the web and this discussion board for this behaviour but couldn´t find anything that really seems to fit my issue.

When beautify is processing my code it´s removing the indentation from all empty lines. So clicking on an empty line after formatting will have the cursor stay at the very first position. Not the expected level of indentation.

image

Is there a way to keep this from happening?

I tried changing options from the atom-whitespace package to see if it would have an effect but couldn´t get any result.

I feel like a lot of people would be affected by this but, like mentioned, couldn´t find anything about this.


#2

This is done by the whitespace package (a core one). It is expected behaviour, but you can disable it by disabling the whitepsace package.

Pressing tab at one of those lines will jump the cursor to the proper position though, so that’s not really a problem. You’ll also note it only removes the whitespace on save, so you can edit things just fine with all the whitespace you like when actively working on something (and not saving in between).


#3

I tried this and unfortunately, even having the whitespace-package disabled, auto-formatting with atom-beautify still removes these whitespaces. And since I auto-formate my code quite frequently - not only on save - this becomes a bit frustrating some times.

This is why I thought there must be a way to keep atom-beatuify from doing this. I like having my code well formatted while writing it without having to worry about doing it by hand. But the removed indentation takes some of the fun out of it. (It´s true that a tab gets me back to my expected indentation level. It´s still a step that could be avoided, so I thought. Also, in HTML-files, I only seem to jump 1 tab-level at a time.)

Still happy for any leads on how to get around this.


#4

Yeah, I didn’t know whether atom-beautify was doing it too (but it makes sense it does). I just wanted to let you know there’s more than one package doing it.

As for how to disable this in atom-beautify, that could be a challenge. The package itself just uses other external programs as backends (for many languages at least), so they would need to support that option.


#5

alright, got it. thanks for the info. ill get used to it :wink:


#6

As @Aerijo, atom-beautify throws several code formatters into one huge package (for better or worse). I haven’t tried it myself, but I assume that each of them still respects its own configuration option.

For example, to set up js-beautify, you can make use of a .jsbeautifyrc file in your document root, wile JSCS can be setup using a .jscsrc file.