Home > Software engineering >  Vscode move line above a block shortcut key
Vscode move line above a block shortcut key

Time:06-07

Is there any shortcut key to move a line above or below a block? This feature exists in IntelliJ editors and maybe also in visual studio.

You can use Alt Up to move a line up one line. Is there any such shortcut key to move the line above an entire block above?


In the example below, it's to move the line a = 1; above the if block

description

CodePudding user response:

Try using Alt Up, that works for me.

It's also on the context menu if you need it ...

Context

You can also select blocks of code and use the same shortcut to move the entire lot. This would work in your case.

CodePudding user response:

There is no single command for moving current line above/below adjacent block (at this moment), but you can get pretty close by selecting and moving the block instead. Expand selection (ShiftAltRightArrow) and "normal" Move line up/down (AltUp/Down) will come handy here:

  • Related