7

VSCode has the ability to start a multiline selection via:

shift + alt + mouse drag

or

ctrl + shift + alt + arrow key

The problem is that when I'm working across lines of code with empty lines interspersed, if I backspace to remove code to the start of the line, the empty lines are removed with it:

enter image description here

becomes:

enter image description here

How do I get a 'column' selection (as I believe it's called) like with Notepad++'s alt + mouse drag / shift + alt + up/down arrow that operations purely horizontally across rows (which would preserve the new lines here)?

1 Answer 1

6

Answering my own question 'Q & A' style having done some more playing:

I can achieve the desired behavior by starting a selection using:

shift + alt

... and then drag the mouse left or right to start a single line selection, AND THEN start dragging down ...

or by starting a selection using:

ctrl + shift + alt

... and using the left / right arrow key to start a single line selection, AND THEN use the up / down arrows ...

I then get a column / box selection that will not operate on the blank lines in my example above.

Note that (maybe only in my scenario above) I need to start the selection a few characters in to get the column / box selection - starting on the far left doesn't work so well.

This doesn't feel very intuitive at all, but VSCode seems worth it so far!

1
  • Another option: select multiple lines and press <SHIFT>+<TAB> (i.e. "outdent"). It works in that it doesn't delete empty lines, but unfortunately is not exactly the same as "delete".
    – JS.
    Oct 18, 2022 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.