Moving and Copying Lines in VS Code

Published: Monday, July 11, 2022

Greetings, friends! VS Code has useful keyboard shortcuts available for manipulating lines. Below are some of my favorites.

Shortcut (Mac)Shortcut (Windows)Description
Option + UpAlt + UpMove current line up
Option + DownAlt + UpMove current line down
Shift + Option + UpShift + Alt + UpCreate duplicate line above current line
Shift + Option + DownShift + Alt + DownCreate duplicate line below current line
Shift + Command + KShift + Ctrl + KDelete current line

We can use the keyboard shortcut Option + Up/Down (on Macs) or Alt + Up/Down (on Windows) to move lines up and down.

Moving the lines up and down in VS Code.

We can use the keyboard shortcut Shift + Option + Up/Down (on Macs) or Shift + Alt + Up/Down (on Windows) to duplicate lines above or below the current line.

Duplicating lines in VS Code.

We can use the keyboard shortcut Shift + Command + K (on Macs) or Shift + Ctrl + K (on Windows) to delete the entire line.

Deleting lines in VS Code.

I hope you found these keyboard shortcuts helpful!