Convert tabs to spaces package fails


I’m using Atom 1.11.2 on Trusty Tahr.

I select some lines with whitespace at their ends, go to Packages -> Whitespace -> Remove Trailing Whitespace, and those lines have that whitespace removed, and the filename tab shows the file as changed, as expected. If I select those same lines (which begin with tabs), go to Packages -> Whitespace -> Convert Tabs to Spaces, precisely nothing happens, and file remains unchanged.


Do you have a sample file that we can try to reproduce the problem with? Also, can you reproduce the problem using the latest version of Atom? And can you reproduce it in Safe Mode? To launch Safe Mode:

  1. Completely exit all instances of Atom
  2. Launch Atom with the command atom --safe


Reply window here won’t let me attach a text file, but it’s a very straightforward file with only a dozen or so lines of text, most beginning with one or more tabs, possible followed by spaces, then normal text.

With 1.11.2, I noticed that it actually did seem to change at least some of the tabs in the file itself to spaces, but it made no change to the edit buffer, and so arrow-keying over where the tabs were made the cursor skip as if there were tabs, even though a hex dump of the file showed spaces.

1.12.9 is different–it seems to keep the edit buffer and file in sync, but it doesn’t replace every tab.

Safe mode didn’t seem to make a difference.


Can you post the text file as a Gist? I just want to make sure that I’m starting from the same point as you.


I don’t trust Gist to give you an accurate file–it seems to be “smart” about text. You can get it from an old repo of mine:


Also, looking at your code, the function ends with:

return editor.setSoftTabs(true)

Is that actually setting soft-tabs mode in the editor? I certainly don’t want that, and don’t see the reason for it.


Another possible misunderstanding…I just did some experimenting, and it seems that arrow-keys can skip over multiple spaces as if they were tabs even when there are no tabs in the file. I’m not sure if that’s a setting or not.


I haven’t used the built-in whitespace conversion in a while so it took a little catching up on my part …

  1. The whitespace commands you list operate on the entire file, not selections
  2. When I use the “Whitespace: Convert Tabs to Spaces” command, the leading whitespace is converted even on your sample file … verified using “Show Invisibles” enabled
  3. Yes, it sets the softTabs mode on the open editor because it assumes that since you converted the whitespace for the whole file, you’ll want Atom to maintain that and not continue inserting tabs when you just got everything all clean :slight_smile:

Yes, this is a setting called “Atomic Soft Tabs” in the Editor Settings:


Ah, thanks. OK, I have “atomic soft tabs” turned off, and I’ll just have to remember to turn off soft tabs if I ever use that converter (unless you fix that–frankly, I think your assumption is mistaken, and that you’re just causing an unintended and confusing side-effect).

Just so you’ll know where I’m coming from, my current project is 90% C files, in standard Linux Kernel form (which means tabs in the file at standard 8-character indent). That’s good for C, and where I want my editor optimized, but there’s that one pesky HTML file that is just nested too deeply, and looks best with spaces and 2-character indent.

Thanks for the help.