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 + Up | Alt + Up | Move current line up |
Option + Down | Alt + Up | Move current line down |
Shift + Option + Up | Shift + Alt + Up | Create duplicate line above current line |
Shift + Option + Down | Shift + Alt + Down | Create duplicate line below current line |
Shift + Command + K | Shift + Ctrl + K | Delete 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.
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.
We can use the keyboard shortcut Shift + Command + K
(on Macs) or Shift + Ctrl + K
(on Windows) to delete the entire line.
I hope you found these keyboard shortcuts helpful!