Sublime Forum

Shift-tab to unindent current line?

#1

I would like shift-tab to unindent the current line, even if no text is highlighted. Currently, shift-tab will unindent only after I select at least one full line. I would prefer no selection is required to have shift-tab unindent just the current line.

Reason: I am coding in languages which close if-statements with “end”, not brackets, and these “end” are not recognized for auto-unindent. I would like to just type “end” and shift-tab to unindent.

I would prefer this to be the default behavior for Sublime Text (I see no down-side to it), but perhaps I can also do this with a plugin, can someone help me with that?
Thanks

0 Likes

#2

Add this line at the bottom of your User Keybindings (look under the Preferences menu):

<binding key="shift+tab" command="unindent" />

unindent is a built-in command.

Does that work for you? I don’t know whether Jon has left this one out for a good reason, though.

0 Likes

#3

Excellent, guillermooo. Your suggestion works perfectly. I guess I would further suggest this be a default behavior. I’m not aware of any reason not to do this-- shift-tab really has no other function?

0 Likes

#4

I’m working with Ruby in the latest Sublime beta, which closes “if” statements with “end” and no brackets, and it automatically un-indents for me. Maybe it is possible to find the necessary content from the language file and copy it to whichever language file you use.

0 Likes