Last updated: Apr 6, 2024
Reading time·2 min

To move a line up or down in VS Code:
Alt key and the up ↑ and down ↓ arrows.Option ⌥ key and the up ↑ and down ↓ arrows.
You can also view the keyboard shortcuts for your operating system in this table in the docs.
The commands are called:
Key column, the keyboard shortcuts for all operating systems are displayed.You can also use the Command Palette to view the keyboard shortcut:
Ctrl + Shift + P on Windows and Linux.Command + Shift + P on macOS.F1 to open the Command Palette.

The same keyboard shortcuts can be used to move a selection up or down.
Alt (or Option) and the up and down arrow keys to move the
selection.
If you need to change the keyboard shortcuts for the "move line up" and "move line down" commands:
Ctrl + Shift + P on Windows and Linux.Command + Shift + P on macOS.F1 to open the Command Palette.

Enter to
confirm.You can also click on the pencil icon to set a new keyboard shortcut.

Enter to
confirm.I've also written an article on how to enable relative line numbers in VS Code.
You can learn more about the related topics by checking out the following tutorials: