Sublime Forum

V2 - Rollback shift + tab to unindent?

#1

Good afternoon,

I was wondering if is there a way to disable “Shift + Tab” to insert a regular tab, and rollback the functionality to use unindent. I’m so used to this key shortcut, that it’s getting in my nerves.

Thanks!

PS. I love Sublime Text 2, look forward to the final version!

0 Likes

#2

This is actually a bug related to tab_completion.
Hope John fixes it soon I also use this a lot and it’s frustrating.

0 Likes

#3

I did it this way: Preferences->User Key Bindings-> i added this:

{ "keys": "shift+tab"], "command": "unindent" }

Work like a charm. I didn’t discovered any conflicts by now.

0 Likes

#4

[quote=“iamntz”]I did it this way: Preferences->User Key Bindings-> i added this:

{ "keys": "shift+tab"], "command": "unindent" }

Work like a charm. I didn’t discovered any conflicts by now.[/quote]

That’s already on the the Default Key Bindings file, but it needs a context which doesn’t seem to work properly because of tab_completion.

Lines 140 ~ 150:

[code]…

{ “keys”: “shift+tab”], “command”: “insert”, “args”: {“characters”: “\t”} },
{ “keys”: “shift+tab”], “command”: “unindent”, “context”:

    { "key": "text", "operator": "regex_contains", "operand": "\n" }
]

},
{ “keys”: “shift+tab”], “command”: “prev_field”, “context”:

    { "key": "has_prev_field", "operator": "equal", "operand": true }
]

},

…[/code]

Anyway, I tried yours and seems to work nice, so thanks for your solution.

0 Likes

#5

Don’t understand the problem here, or maybe it’s a something related to the OS (I’m on windows).

The context { “key”: “text”, “operator”: “regex_contains”, “operand”: “\n” } mean that you need a “carriage return” in the selection to trigger the unindent.
So if you want to unindent only the current line you have to press CTRL+L to select all the line and after SHIFT+TAB to unindent.
This is how ST1 work and feel right to me.

I tried some other editors (pspad, wordpad, Delphi, …) and my conclusion is that this behavior is common to all.
If you don’t select your text before un/indenting, there’s no standard behavior and it depend of your editor.

0 Likes

#6

I realize it’s a matter of habit, but I agree with bizoo that the symmetry between Tab and Shift+Tab in selected whole lines is pretty clear.

Maybe Shift+Tab could be made to unindent if the previous character was a tab (or the beginning of the line), or do its current thing if it wasn’t. A tab character as a tab trigger wouldn’t make too much sense, would it?

0 Likes

#7

Shift-tab should always be unindent. Period.

I hope this changes with the next ST release.

0 Likes

#8

[quote=“oats”]Shift-tab should always be unindent. Period.

I hope this changes with the next ST release.[/quote]

Like I already said, ST1 don’t work like this so it looks that this behavior was only present in the beginning of the alpha of ST2. I didn’t notice it myself.
So if you want it, do it yourself https://forum.sublimetext.com/t/v2-rollback-shift-tab-to-unindent/1630/1#p9525

0 Likes

#9

It’s great pain in the ass for me. For now I decided to downgrade to Alpha Build 2056 - last version I found without this bug (feature??).

0 Likes

#10

What ST1 did is irrelevant. The best default behavior for Shift-tab is unindent. I think that makes the most sense for most people. Key bindings are always available for those who want something different.

0 Likes

#11

Yes it is… as a former ST1 user I expect that the behavior of ST2 don’t change when there’s no need to change it.
But actually your right, shift+tab was not used in ST1…

Your mind, don’t speak for everybody please.

Your right here !!!
Add this line to your user key binding file and enjoy:

{ "keys": "shift+tab"], "command": "unindent" }

What I need at the end of the day is a way to always insert a tab when tab key is used for something else (eg: snippets).
Shift+tab look like a good choice for this so why change it ?

And finally a question:
Tab don’t indent line when the line is not selected, it only insert a tab char at the cursor position.
So why shift+tab must unindent the line in the same context ?

0 Likes