Home Download Buy Blog Forum Support

indent and unindent with partial-line selection

indent and unindent with partial-line selection

Postby adzenith on Thu Mar 31, 2011 12:20 am

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:
Code: Select all
   |   line 1
   |   line 2

If I hit shift+tab twice, I end up with this:
Code: Select all
|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:
Code: Select all
|      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.
Code: Select all
   |   line 1
   |   line 2

becomes
Code: Select all
|   line 1
   |line 2

after hitting shift+tab once, and
Code: Select all
|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.
adzenith
 
Posts: 1215
Joined: Mon Oct 19, 2009 9:12 pm

Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], fizzicist and 11 guests