Always insert tab at current cursor location, even if only whitespace exists to left and right of cursor


#1

If there is only whitespace to the left of the cursor position and there is additional whitespace to the right, pressing tab first jumps to the end of the line and then inserts another indentation level.

If there are some non-whitespace characters to the left or right of the cursor, the tab is inserted at the present cursor location (and the cursor doesn’t jump to the end of the line). This is how Sublime works all the time.

I would like the behavior to be the same no matter what: a tab is inserted at the present cursor location without ever jumping to the end of the line.

(Below, “|” is the cursor location, “----” is relevant whitespace)


TAB with whitespace to the left and right

<div>
      <div>
      |----
      </div>
</div>

… press TAB

<div>
      <div>
      --------|  <--- whitespace inserted at end of line, including whitespace that existed
      </div>
</div>

TAB with characters to the left and whitespace to the right

<div>
      <div>
      hello|----
      </div>
</div>

… press TAB

<div>
      <div>
      hello----|----  <--- whitespace inserted at cursor location
      </div>
</div>

I almost can get the behavior that I want by changing the tab key to be editor:indent-selected-rows with two exceptions:

  1. I can no longer insert a tab in the middle of a line, and
  2. I can no longer insert a tab on an empty line.

Is there any way to get tab behavior I prefer?


#2

There are some changes happening in Atom to make it possible to “break apart” the “molecular leading whitespace” feature. I don’t know when they’ll make it down to Stable (no sooner than v1.9, I believe) … but I think those changes would be a requirement of what you’re asking for.


#3

Okay, excellent. Thank you for the intel! I tried a bit of searching for this “molecular leading whitespace” term you’ve used and couldn’t turn up anything relevant. Do you have any additional resources that’d help me keep an eye on the progress?


#4

We don’t really have a unified term for the fact that multiple leading spaces are unified into single virtual characters based on tab size. If you want to track progress on what will enable the change, you can search for PRs referring to the DisplayLayer.


#5

Any news on this?

Binding tab to editor:indent-selected-rows still breaks tab insertion at the beginning of an empty line.

Edit: I see you said 1.9 and we’re still on 1.8. I guess we’ll have to wait a bit longer.


#6

You can always use the beta channel which is currently on v1.9.x.