Sublime Forum

Edit multiple lines without deleting blank lines?

#1

It is very often the case where I have code like this:

[code]

  <input whatever/>

  <input something/>

  <input type="submit"/>  

</form>[/code]

Note the blank lines as well as the whitespace in front of all the code.

I want to reformat the code to get rid of the whitespace in the front, so its like this:

[code]

[/code] My first instinct is to place my cursor at the start of the first line, then hold ALT + CTRL and then move the cursor down until I'm at the last line, then just press press DELETE 4 times. I would expect all the lines of code to simply move to the left 4 spaces and then I'd be done. But no... it ends up like this: [code] [/code]

This is because part of my selection included blank lines. Pressing DELETE will remove those blank lines, because obviously there is no characters on those lines to delete. I know from a technical standpoint that this behavior is technically correct. But it does not seem to be intuitive at all. When are people ever going to make multi-line selections like this and WANT to delete the blank lines, messing up the formatting and whitespace they put in place?

Also, this behavior is not consistent with the behavior of selecting multiple lines (including blank lines) and pressing TAB. When you do this all the lines WITH CODE get a tab at the front but the blank lines DO NOT get the tab. This feels like proper behavior, but it’s not the same thing that happens with the above DELETE situation. I would want the DELETE situation to behave more like how the TAB situation treats blank lines.

Is there a way to accomplish what I want without manually CTRL+Clicking each line I want to change, carefully avoid the blank lines?

0 Likes

#2

Why not just select everything and press shift+tab?

0 Likes

#3

Hmmm didn’t know about that one. Thanks

0 Likes