Soft Tabs are harder than they should be


#1

I have soft tabs enabled, but it seems to still be outputting tabs instead of spaces. I thought maybe it just used the same tab character in the invisibles, but I opened the file in Sublime and it is in fact a tab.


#2

Atom will try to auto-detect the tab settings. Is it possible that the first indent in that file is a tab?


#3

It seems the soft tabs settings is completely ignored, because hard tabs are also harder than they should be. When invisible characters are made visible, it always shows four spaces regardless of whether the soft tabs setting is set to true or false. Furthermore, when tabs are copied, regardless of whether they’re soft or not, they’re always four spaces once pasted somewhere else. I haven’t yet tried saving a file and opening it back.


#4

I hadn’t realized it would auto-detect, but these files were generated by Laravel, so I guess they could have hard tabs coded in. I opened a new file and it started off with spaces just fine. Not exactly PSR-2 friendly, but I guess a project wide find/replace will fix that for now.


#5

It seems that with invisibles on, you see the spaces as dots at the start of the line, but the dots aren’t shown after text has started.

I’d look into more, but I can’t find which package is controlling the invisibles setting…


#6

I always get hard tabs regardless of my settings or what language I’m in or what is already in the file.


#8

After doing a project wide find & replace, it’s all soft now.


#9

I too got hard tabs with soft tabs enabled in settings, even though the first indentations in the file were spaces. Interestingly, after I ran “Untabify” (https://atom.io/packages/tabs-to-spaces), closed and re-opened the file, it now seems to properly create soft tabs.

Wonder if the auto-detect somehow fails as long as there are any hard tabs left in the file?


#10

Do hard tabs actually work for you guys, @mieky @MrTravisB ?

I’m a hard-tab person, but they’re not working for some of us, so I was wondering if they are for you.

Thanks!


#11

Hard tabs (or smart-tabs in my case) are a pain for me too. The best method I have come up with is find-and-replace and then relaunch if its still not working.

So I would generalize the problem as:

More control over tabs is needed

The problem is the whole auto-detect tab thing. I’m fine with auto detect for consistency, but we need a way to override the auto-detector’s decision. Sublime has this awesome tab settings menu that solves the problem. Does such a plugin yet exist for Atom?


#12

You can override the editor’s decision for a particular file with Cmd-S P, Editor: Toggle Soft Tabs. It only lasts for as long as you have the file open, but it’s better than nothing. This definitely does need a better solution.


#13

Hard tabs are not working for me either - working in javascript files with javadoc style file headers it seems to default to soft-tabs even though that contradicts my settings. Its at the point where I am going to go back to Sublime Text until it is resolved. Tabs & Spaces should not be this hard …


#14

I just ran into this when creating a Markdown document. At first, everything was okay. Then I saved the file in ~/Documents. Atom assumed I wanted ~/Documents to be my project directory, and suddenly started using hard tabs in the file.

Workaround was to create ~/Documents/markdown and launch atom from there.

It would be nice if Atom respected the setting. Or if could be set on a per file type basis.


#15

I’ve forced “Soft Tabs” putting “two spaces” (SpaceSpace) in the “Invisibles Tab” option.


#16

I have the same problem with 0.210 - soft tabs is enabled, but they are not replaced by spaces. Very annoying for python development! Anyone else is experiencing this? Looks like a basic feature is broken, or I am doing something wrong.


#17

There is an open issue on this here:

The solution is to convert all tabs to spaces in the file, save it, close it and reopen it. Then the soft tabs will work fine.


#19

Thanks for this tip. I used the tabs-to-spaces package to get rid of all tabs and was still getting new hard tabs when indenting… until I saved, closed and re-opened the file. Looks like the indenting logic routine has a caching problem.


#20

This is still a problem in Atom 1.16.0. Perhaps the caching problem @quantum_coder mentions is what I’m being put off by, but my experience is that it’s not behaving in a predictable manner. I’ve tried to add all sorts of packages to fix the problem, but each in their own way have only made it sort of worse because the core of Atom is so messed up. I really wish the entire whitespace preference code could be wiped from the source of Atom and rewritten to be much less smart and much more predictable.