我试图找到在Visual Studio代码中复制一行的快捷方式(我使用1.3.1),我尝试了明显的CTRL + D,但似乎不起作用。


当前回答

Mac:

重复行下:shift + option +↓

重复排列:shift + option +↑

其他回答

点击文件>首选项>键盘快捷键:

在键盘快捷键中搜索copyLinesDownAction或copyLinesUpAction

通常是SHIFT+ALT +↓


Ubuntu更新:

Ubuntu似乎隐藏了这个快捷方式,不让VSCode看到(也就是说,它自己可能会使用它)。在GitHub上有一个问题。

为了在Ubuntu中工作,你必须定义自己的快捷方式,例如使用ctrl+shift+alt+j和ctrl+shift+alt+ k复制一行,你可以使用一个键绑定。Json是这样的:

[
    { "key": "ctrl+shift+alt+j", "command": "editor.action.copyLinesDownAction",
                                    "when": "editorTextFocus && !editorReadonly" },
    { "key": "ctrl+shift+alt+k", "command": "editor.action.copyLinesUpAction",
                                    "when": "editorTextFocus && !editorReadonly" }
]

另外2个非常有用的快捷键是上下移动选定的行,就像sublime text…

{
  "key" : "ctrl+shift+down", "command" : "editor.action.moveLinesDownAction",
  "when" : "editorTextFocus && !editorReadonly"
},

and

{
  "key" : "ctrl+shift+up", "command" : "editor.action.moveLinesUpAction",
  "when" : "editorTextFocus && !editorReadonly"
}

窗口:

重复行下:Ctrl + Shift + D

Mac:

重复行下:shift + option +↓

重复排列:shift + option +↑

Ubuntu:

重复排列:Ctrl + Alt + Shift + 8 重复行下:Ctrl + Alt + Shift + 2