How do I duplicate a line or selection within Visual Studio Code?

The commands your are looking for are editor.action.copyLinesDownAction and editor.action.copyLinesUpAction.

You can see the associated keybindings by picking: File > Preferences > Keyboard Shortcuts


Shift+Alt+Down and Shift+Alt+Up


Shift+Option+Down and Shift+OptionUp


Ctrl+Shift+Alt+Down and Ctrl+Shift+Alt+Up

(Might need to use numpad Down and Up for Linux)

Furthermore, commands editor.action.moveLinesUpAction and editor.action.moveLinesDownAction are the ones to move lines and they are bound to Alt+Down and Alt+Up on Windows and Mac and Ctrl+Down and Ctrl+Up on Linux.

Leave a Comment