Can't enter hard tab


#1

My tab key is emitting spaces no matter what I do. I’ve turned the Soft Tabs option on and off. I’ve tried it in safe mode. I’ve tried it in indentation (beginning of line) and spacing (middle of line).

I’ve been using atom for weeks and not noticed this before, but I think this is the first time i’ve edited an old file that uses hard tabs.

Windows 8.0 – Atom 0.119.0


#2

Would you mind running this from the developer console with the problem file being active

atom.workspace.getActiveEditor().softTabs

and let us know if it returns true or false.


#3

Thanks for the quick response.

It says true but the checkbox is definitely off.

If I set the value to false then it behaves correctly.


#4

There are some heuristics applied when opening a file to attempt to preserve the existing indentation style (regardless of your preference setting) of the file. Might there be some lines at the beginning of the file that are indented with spaces? Perhaps in a block comment, or some such?


#5

If I make the first indent a hard tab then atom.workspace.getActiveEditor().softTabs returns false and it works ok. Apparently atom decides whether I’m using hard tabs and ignores the setting. This is a real problem.


#6

Our posts crossed in the mail but you are right. Is it overriding my choice which is very uncool. Making it impossible to type a tab is a show-stopper. If someone insists on this feature then it should be an optional feature.


#7

I will create a quick work-around package that forces soft-tabs off. I personally never use soft-tabs. I want to be able to type spaces or tabs whenever I feel like it.


#8

The reason behind this is, as I mentioned in the previous reply, to prevent mixed indentation. So if you edit a file someone else created, and they decided to use hard tabs, then it’s reasonable that you should continue to use hard tabs.

This is not a bug, this is working as intended. I’m not aware of any built-in support for disabling this functionality, but you might be in luck if you use the Overrides package. I believe (although not verified it) that an unintended side effect of that package is that it overrides the heuristically configured tab setting.
Just create a scope override similar to

'source':
  'softTabs': false

#9

I agree that there should be a way to turn this functionality off. I’ll see if I get time to send a pull request for it.


#10

This is partly what my tabs-to-spaces package is for. You can:

  1. Tabify or untabify any document on command
  2. Set it to tabify or untabify all documents on save

This should allow you to turn off softTabs and work the way you want.


#11

That’s why I love atom so much. Start with a lot of rough edges but make it easy to polish off. Darwin would be proud. I am very curious what Atom will evolve into.

My only fear is that it will get hard to find and choose from the plethora of packages as it is with npm. But better to have too many than too few.


#12

I suspect at some point someone will come along and do for Atom what Bozhidar Batsov and Prelude did for Emacs. Essentially, Prelude is a version of Emacs that is pre-configured with a bunch of add-on packages and defaults that make it easier to get into than vanilla Emacs for the modern programmer. I think before that happens though, Atom will need to stabilize somewhat.


#13

This is incredibly frustrating. I need control over whether my tab key inserts a tab or inserts spaces, and ideally I would like to be able to rely on that behavior being consistent and not having to have invisibles turned on to police my own text editor. While I don’t disagree with the worthiness of this feature for some people, such globally controlling behavior needs to be disablable in a poweruser tool.

I can’t even select a tab character and copy and paste it without it getting turned into spaces! Maybe that would work if I disabled Auto Indent on Paste, but I don’t want to disable that. I just want to write a tab.

Side note: The auto-detect doesn’t even work properly to begin with. I have a file that has a single space (not double; my tab size is set to 2) near the beginning of the file. Everything else is indented with tabs but it still inserts spaces whenever I type a tab.


#14

I strongly encourage you to simplify this with a radio for one of these three:

  • always use tabs
  • always use spaces
  • detect and adapt

Your current detector is really bad. It samples ONLY THE FIRST item, so if it finds spaces and the entire rest of the file is tabs you end up with the wrong thing.

I hope you’ll understand: projects have policies on what to use, and the editor should not be the one controlling the decision. The human must have control.


#15

This is a known issue and is being tracked here:


#16

It turns out this is a duplicate of this topic:

In order to keep conversation in one place, we try to unify conversation under one topic. I’m going to close this as duplicate, please continue the conversation on the original.

Thanks!


#17