Sometimes tab inserts spaces, even with soft tabs off


This is a known issue and is being tracked here:


Currently that ticket is locked. No progress in a long time :T
It’s such a basic thing!


This Package fixed this issue for me:

Installed, pressed Ctrl Shift P
Toggle Guess Indent

File started using the indentation I was clearly using on the whole file.


Soft tabs are off… and my file does not actually start with spaces at all… Yet I’m still getting soft tabs on a php file… no idea. Nvm, it guesses indentation based on the first non comment indentation.

This seems like a cruel joke by space fans.


A fix for this was merged and should be available in the next Atom release (v1.0.8):


I have found the vanilla solution. As mentioned earlier, it will detect the method your using, however the setting is what sets it if it can’t detect it. So, as long as you have soft tabs off, and the tab method already used in the text is hard tabbing, then it works just fine. The option doesn’t set it no matter what, it sets it if it can’t find the method. Hope this helps.


Actually, the new setting “Tab Type” should override things if you set it to something other than Auto:


Thank you for adding the Tab Type setting. This works much better than before.

However can I just add that keeping the “Soft Tabs” checkbox is rather confusing. We now have a “Soft Tabs” checkbox and a “Tab Type” drop down. In fact it’s not even clear to me how these two settings work together.


Upon further consideration, I’m guessing that this affects the decision when there is not enough information to guess in “Auto” mode (such as when creating a new document). If this is the case, my I make the following UX suggestions:

First of all, move the Soft Tabs checkbox under the Tab Type drop down and rename it to “Prefer Soft Tabs When Possible”, and secondly, only enable it when the Tab Type is set to Auto. When tab type is set to hard or soft explicitly, these should always dictate the tab type. Therefore the soft tabs setting should really only apply when set to Auto.


I’m apparently quite late to this discussion - but is anyone else disconcerted that there isn’t a more file-by-file way to explicitly indicate whether or not to use soft tabs? I have files that use tabs and some that use spaces, so a global setting for the editor is really a klunky solution. Does anyone really use one or the other exclusively? I’d rather see this as a “mode” per file so I can keep my sanity.


I do, actually.

But, to address your other concerns, Atom’s auto mode follows whatever it determines is the indentation scheme for the current file. If your files exclusively use one or the other indentation scheme, then auto is probably what you want.


I agree with you that the idea of auto is what I want, but in practice it often chooses the wrong thing, and what I was looking for is a way to tell atom how to choose in a more explicit way.


is anyone else disconcerted that there isn’t a more file-by-file way to explicitly indicate whether or not to use soft tabs?

I fully agree! I came here to ask if this feature is available in Atom, before opening a bug (probably unnoticed among the thousands of currently opened bugs: the price of success!).

My favorite “dumb” editor (SciTE) allows to change the tab settings per file (buffer): soft or hard (and a button to convert the indentations in the file), size of tab (and size of indentation, but that’s something I don’t want different!).
I don’t understand why I can see (and change) the line ending (LF vs. CRLF), but not the tab settings.
Looks like a very basic feature missing from the core.
Note that I am glad there is auto-detection, that’s the usual wanted behavior, but sometime it gets it wrong (got tabs in a file indented with spaces), or sometime we just want to override a wrong guess or just need to enter a tab, etc.

I hope this is a future, planed improvement.


I’m having problems with this too. I have a file with 0 tabs in it at all, yet when I press the tab key it inserts a tab. I have soft tabs on auto. Why would it think I need tabs? I can convert tabs to spaces, and yet when I press tab again it inserts another tab. So frustrating!


Try converting all tabs to spaces and then close and reopen the file. It makes its “autodetect” determination when the file is opened and doesn’t change its mind afterwards. If you want it to always insert spaces, set “Tab Type” to “soft”.


I mean, I want it to always insert spaces in this file, but not in a file with tabs in it. So “auto” is definitely the setting I want.

I think there’s a bug around untitled (never saved) files. If I do as you suggest with a file on disk, it works. If I make a new file, it always uses tabs and there’s nothing I seem to be able to do about it. There’s no way I can reopen it—or is there some way I can rerun the autodetection? In Sublime Text, converting tabs to spaces or vice versa also changes future insertions, which I was hoping would happen here.


It sounds like you need to enable “Soft Tabs” also:

This way, if a file is completely empty (like when you open an untitled buffer), it will default to spaces instead of tabs.


Aha! I totally missed that—it’s not down with the other tab options. (Looks like the options are in alphabetic order rather than some logical grouping; the other tab options just happen to start with the word “tab”.)


I look forward to a resolution to this issue with every single release but it never comes. I have soft tabs disabled, but auto-detect enabled. Atom uses spaces for tabs almost every time even in a file where there are zero soft tabs. I keep erasing it and trying to replace it with a tab character but it doesn’t work. I end up doing a find and replace.

For now, I’ll just disable the auto-detect since most of our work uses actual tabs.


I had to disable soft tabs, set tab type to hard, and close/open Atom again to get it to accept the right type of tabs. Before this it would also enter spaces, not matter which settings I changed.