Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate line in Visual Studio Code

I am trying to find the shortcut for duplicating a line in Visual Studio Code (I am using 1.3.1) I tried the obvious CTRL + D but that doesn't seem to work.

like image 709
TheWebGuy Avatar asked Aug 02 '16 17:08

TheWebGuy


3 Answers

Click File > Preferences > Keyboard Shortcuts:

enter image description here

Search for copyLinesDownAction or copyLinesUpAction in your keyboard shortcuts

Usually it is SHIFT+ALT +


Update for Ubuntu:

It seems that Ubuntu is hiding that shortcut from being seen by VSCode (i.e. it uses it probably by its own). There is an issue about that on GitHub.

In order to work in Ubuntu you will have to define your own shortcut, e.g. to copy the line using ctrl+shift+alt+j and CTRL +SHIFT + ALT + k you could use a keybindings.json like this:

[
    { "key": "ctrl+shift+alt+j", "command": "editor.action.copyLinesDownAction",
                                    "when": "editorTextFocus && !editorReadonly" },
    { "key": "ctrl+shift+alt+k", "command": "editor.action.copyLinesUpAction",
                                    "when": "editorTextFocus && !editorReadonly" }
]
like image 144
DAXaholic Avatar answered Oct 16 '22 12:10

DAXaholic


The duplicate can be achieved by CTRL+C and CTRL+V with cursor in the line without nothing selected.

like image 31
rylek90 Avatar answered Oct 16 '22 12:10

rylek90


You can use the following depending on your OS:

Windows:

Shift+ Alt + or Shift+ Alt +

Mac:

Shift + Option + or Shift +Option +

Linux:

Ctrl+Shift+Alt+ or Ctrl+Shift+Alt+

Note: For some linux distros use Numpad arrows

like image 134
Mwiza Avatar answered Oct 16 '22 11:10

Mwiza