Duplicate line in Visual Studio Code

后端 未结 13 1555
有刺的猬
有刺的猬 2020-12-22 23:25

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

相关标签:
13条回答
  • 2020-12-22 23:49

    Search for copyLinesDownAction or copyLinesUpAction in your keyboard shortcuts

    Usually, it is SHIFT+ALT+

    0 讨论(0)
  • 2020-12-22 23:50

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

    0 讨论(0)
  • 2020-12-22 23:52

    Click File > Preferences > Keyboard Shortcuts:

    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" }
    ]
    
    0 讨论(0)
  • 2020-12-22 23:52

    VC Code Version: 1.22.2 Go to: Code -> Preferences -> Keyboard Shortcuts (cmd + K; cms + S); Change (edit): "Add Selection To Next Find Match": "cmd + what you want" // for me this is "cmd + D" and I pur cmd + F; Go to "Copy Line Down": "cmd + D" //edit this and set cmd + D for example And for me that's all - I use mac;

    0 讨论(0)
  • 2020-12-23 00:03

    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

    0 讨论(0)
  • 2020-12-23 00:05

    Ubuntu :

    • Duplicate Line Up : Ctrl + Alt + Shift + 8
    • Duplicate Line Down : Ctrl + Alt + Shift + 2
    0 讨论(0)
提交回复
热议问题