Indentation Issue with brackets


Hi All, I’ve just stumbled upon Atom and am REALLY liking it. However there is one matter that is particularly confusing to me and that is how it handles indentation. I’m looking at some javascript that I wrote with the Kate editor and, in certain instances particularly with brackets, I seem to be missing tabs. See the highlighted text in the image below to see what I’m talking about.

I also examined this with both nano and gedit in addition to kate and they both displayed the correct number of tabs. What might be going on here?


Perhaps there is a mix of tabs and spaces that Atom fails to handle properly? You can try to toggle invisibles to see if this is the case: open the Command Palette (ctrl+shift+P) and search for toggle invisibles.


Thanks for the reply! I did as you said and it seems as though the first line is indented by four spaces and then the next line has a single tab. See below:

What would you advise?


Whitespace package has a command “Convert tabs to spaces”. Spaces are generally more predictable, so I’d stick with these in the future.

But before applying it, I’d rather head into Atom’s main settings and adjust “Tab length” so this code looks fine as-is. Then apply the conversion, then adjust the tab length to your liking.

Sometimes, when indentation is broken, Ctrl+Shift+P and auto indent helps.


Thanks @D_side, I played around with the code a little and think I see what’s going on. In my estimation, Kate seems to use one tab to for its auto indentation and sets the tabstop according to the context. The other text editors that I’ve inspected this with (gedit, vi, nano) seem to understand this variable width tab but Atom does not. You can check out the code snippet here. Will investigate your recommendations though.


Figured it out. Seems as though I was wrong about the tab-stops. Kate uses an 8-space tab where as the default in atom was 2. I just had to go into settings and switch it and everything rendered correctly.


Alright, turns out that it’s not quite resolved. It looks like my previous text editor used both hard and soft tabs based on context. Apparently vim, jedit and others do this as well. Atom, however does not. I figured that it might just be worth reformatting my code as Atom is not the only text editor that doesn’t deal with this.


Atom does a poor job of implementing tabs and spaces, in my opinion. I’ve had nothing but problems from it when going to/from to other editors like Sublime. This causes SO MANY problems when Python programming.


Have you searched for packages with the tab keyword?


I have. My Atom has Tabify, Untabify and Untabify All. Using them did not seem to resolve the issues with “improper indentation” type errors, though when you look at the code there are no obvious indentation issues. It is only when you ‘back up’ with the Backspace, all the way up to the ends of previous lines, that you see that Atom is not handling these tabs and spaces properly. And, with Python that is a big no no. I will keep an eye out for Atom to see if things improve in the future. Thanks for getting back to me.