Home Download Buy Blog Forum Support

Edit multiple lines without deleting blank lines?

Edit multiple lines without deleting blank lines?

Postby jakobud on Fri Dec 09, 2011 8:47 pm

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

Code: Select all
    <form>

      <input whatever/>

      <input something/>

      <input type="submit"/> 

    </form>

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: Select all
<form>

  <input whatever/>

  <input something/>

  <input type="submit"/> 

</form>

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: Select all
<form>
  <input whatever/>
  <input something/>
  <input type="submit"/> 
</form>


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?
jakobud
 
Posts: 37
Joined: Wed Feb 17, 2010 6:05 pm

Re: Edit multiple lines without deleting blank lines?

Postby C0D312 on Fri Dec 09, 2011 9:45 pm

Why not just select everything and press shift+tab?
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: Edit multiple lines without deleting blank lines?

Postby jakobud on Sun Dec 11, 2011 5:56 am

Hmmm didn't know about that one. Thanks
jakobud
 
Posts: 37
Joined: Wed Feb 17, 2010 6:05 pm


Return to Technical Support

Who is online

Users browsing this forum: No registered users and 9 guests