Tab key not respecting tabLength


I’m having a hard time getting tabs to behave like I expect. I have set tabLength to 3 (using the settings > editor panel), and I have also mandated soft tabs and turned on the indent guide.

The expected behavior is that when I press ‘tab’ (i.e on a new line) I will get 3 spaces. I also expect the indent guides to be lined up 3 spaces apart. What I get is a 4-space tab, and indent guides that are 4 spaces apart. In fact, nothing I do seems to actually change the size of the tabs or indent guides, including reverting to the default setting of 2.

AutoIndent is off, for now. I am using the consolas font family, but I have also tried courier just to make sure it wasn’t a monospacing issue. I’m working on Python file, and Atom has the grammar properly identified. This is a day-old install of Atom under Windows 10. I have restarted Atom a couple of times and tried --safe, with no effect.

My editor settings in the config.cson file show that my inputs in the config panel have been accepted:

atomicSoftTabs: false
autoIndent: false
autoIndentOnPaste: false
fontFamily: "consolas"
fontSize: 16
scrollPastEnd: true
showIndentGuide: true
showInvisibles: true
tabLength: 3
tabType: “soft”

Any idea what I’m doing wrong here?



It sounds like there’s a language-specific tabLength setting. Look in your config.cson to see if there’s a tabLength setting under .source.python. If not, post the list of packages you have installed and we might be able to figure out which package is enforcing its settings.


Thanks for your reply! There is virtually nothing else in my config.cson file. There is the ‘core’ stuff:

themes: [

And then my userID under exception-reporting.

The only package that I’m using is remote-sync-pro 5.1.1, for using sftp to keep a local workspace synced with the remote server. I have gone ahead and disabled that just to eliminate it from the equation. I restarted Atom and the behavior hasn’t changed.

I think you are onto something, though. I created a new file and selected the Python grammar, and was getting 4-space tabs. But then I created a new file and left the grammar alone (plain text default), and it’s doing 3, exactly like I expect! Other grammars (C++, HTML) are also giving 3-space tabs.

Before asking this question I dug down into the language-python core package. It shows “Unscoped value: 3” for all of the tab lengths…I haven’t messed with anything there. Where else could a Python-specific setting be hiding?

Thanks again!


I don’t know.

Try adding this at the end of config.cson:

    tabLength: 3


You got it! Your addition fixes the .py files!

And just as you sent that, I locked on to this:

Check out the code block that the accepted answer suggests (with ‘source’ and ‘python’ swapped). Your patch works, so it’s probably good that we have this solution in the forum for future reference. I’m probably not the only one scratching my head about this.


Scope names work like CSS classes, so the order doesn’t matter.


Python files default to a tab length of 4 in accordance with PEP-8. I see you’ve already figured out how to override it through the config.cson, though you can also do so by navigating to language-python's settings and changing the tab length there (Settings -> Packages -> Language Python).


Woah. I had tried that, but it seems that I got bit by a minor bug (feature?).

It looks like the settings panel only respects the input in language-python if it’s different from the main editor setting. So if I set the main tabLength to 3, then this is disregarded in Python files…but in the Python settings it says “Unscoped value: 3” and if you try to put a ‘3’ there it just wipes it out. But if you change the main setting to 6 or something (or even the default of 2), this is still disregarded in Python files…but then when you update the Python-specific value it sticks. And, in fact, writes the very block of code that @DamnedScholar provided earlier to the config.cson file.

Thanks again, everyone!


Python is a little different than many languages in its highly opinionated guidelines about formatting and whitespace (as wliu mentioned, see PEP-8). So the author of the Python language package made a decision to comply with that and override the global editor default, and stick to 4. As you have seen, it’s possible to override it, but that is the reason that Python ignores the global setting, unlike most languages. It’s just a convention adopted by the Python community at large. Since indentation is literally syntax in Python, this is an important topic in that community.


@tangledhelix Yeah, it’s not my intention to start a holy war about Python indentation. But I inherited a big glob of code that is neatly 3-spaced…it’s an institutional thing, so I don’t want to reformat it, even if that was easy/automatic. I just need the editor to respect it. Thanks to this great community, I have a working solution!


@nova461: Whoops, I forgot about that Settings View bug. The good news is that it should be fixed starting in Atom 1.20.0 :smile:.