How to Move a Line Up or Down in Visual Studio Code for Mac

Visual Studio-CodeEditorKeyboard Shortcuts

Visual Studio-Code Problem Overview


I'm familiar with how to move a line up or down in other editors, like Atom and Sublime.

How is this done in Visual Studio Code for Mac?

Visual Studio-Code Solutions


Solution 1 - Visual Studio-Code

In Visual Studio Code for Mac...

>To move a line UP: + (alt + up arrow key) > >To move a line DOWN: + (alt + down arrow key)

See here for a reference on Basic Editing Key Bindings in Visual Studio Code.

Solution 2 - Visual Studio-Code

For Windows:

  • To move a line UP: Alt + (alt + up arrow key)
  • To move a line DOWN: Alt + (alt + down arrow key)

Solution 3 - Visual Studio-Code

In Visual Studio Code for Mac for me it is:

>To move a line UP: +shift+ (alt + shift + up arrow keys) > >To move a line DOWN: +shift+ (alt + shift + arrow down keys)

I do have IntelliJ IDEA Keybindings installed.

Solution 4 - Visual Studio-Code

You can find the corresponding commands in the Selection menu (Move Line Up and Move Line Down) together with currently set short-cuts.

Additionally, if you launch the command palette (View/ Command Palette) while you have an open document you also find them there (type "move" or "line").

Solution 5 - Visual Studio-Code

If you are looking for Visual Studio (2019) on Windows and found yourself here, the default keyboard shortcut is the same as for Visual Studio Code as shown by @tapu74.

  • Move line up = Alt + Up
  • Move line down = Alt + Down

To change the shortcuts, say to match Notepad++ where the shortcut is Ctrl + Shift + Arrow:

  • Tools > Options > Environment > Keyboard
  • In Show commands containing enter Edit.MoveSelected
  • Change Edit.MoveSelectedLinesUp or Edit.MoveSelectedLinesDown as required

Solution 6 - Visual Studio-Code

FOR VS CODE MAC:

opt + UP, opt + DOWN

Solution 7 - Visual Studio-Code

I was trying to move the selected lines down but couldn't move it. I can easily move the line up. Then I realised that I needed to create more lines downwards as I was trying to move the code to undefined area. First create some lines by pressing enter.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjacefarmView Question on Stackoverflow
Solution 1 - Visual Studio-CodejacefarmView Answer on Stackoverflow
Solution 2 - Visual Studio-Codetapu74View Answer on Stackoverflow
Solution 3 - Visual Studio-CodeAnima-t3dView Answer on Stackoverflow
Solution 4 - Visual Studio-CodeÁlvaro GonzálezView Answer on Stackoverflow
Solution 5 - Visual Studio-CodeAlainDView Answer on Stackoverflow
Solution 6 - Visual Studio-CodejacekView Answer on Stackoverflow
Solution 7 - Visual Studio-CodeOrcunView Answer on Stackoverflow