Sublime Forum

Indent and unindent with partial-line selection

#1

When a line is only partially selected, unindent and indent (shift+tab and tab) can do unexpected things. Say I have this code, and the selection goes from pipe to pipe:

| line 1 | line 2
If I hit shift+tab twice, I end up with this:

|line 1 | line 2
If I then hit tab twice in a reactionary attempt to fix my wrongdoing (as I am wont to do), I get this:

| line 1 | line 2

Clearly if I select an entire line (including the newline) I don’t want to indent the next line—I think “indent” has the correct behavior here. However, I think “unindent” does the wrong thing: perhaps it could ensure that the selection on the last line remains inside the line after unindenting? E.g.

| line 1 | line 2
becomes

| line 1 |line 2
after hitting shift+tab once, and

|line 1 line| 2
after hitting shift+tab a second time.
Clearly this has the side-effect of a semantic change to my selection, but I’d rather have that than have to manually fix the last line. And if the selection remains the same number of characters inside the last line after both unindent and indent, then it would be semi-symmetrical as long as the line didn’t become shorter than the amount of whitespace you’ve chopped off with unindent.

0 Likes