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


当前回答

根据操作系统的不同,可以使用以下方法:

窗口:

帽子Shift + Alt +↓还是是Shift + Alt +↑。

Mac:

Shift +Option +↓或Shift +Option +↑

其他回答

Mac:

重复行下:shift + option +↓

重复排列:shift + option +↑

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

通常为SHIFT+ALT+↓

可以创建仅在Vim for VSCode打开并处于特定模式(即“正常”、“插入”或“可视”)时才激活的键绑定。

为此,使用Ctrl + Shift + P打开VSCode的命令面板,然后搜索“首选项:打开键盘快捷键(JSON)”选择这个选项会打开keybindings.json。在这里,可以添加自定义绑定。

例如,这里是经典的VSCode命令移动/复制行调整,以方便在Vim中使用。

    [
      {
        "key": "alt+j",
        "command": "editor.action.moveLinesDownAction",
        "when": "editorTextFocus && vim.active && vim.mode == 'Normal'"
      },
      {
        "key": "alt+shift+j",
        "command": "editor.action.copyLinesDownAction",
        "when": "editorTextFocus && vim.active && vim.mode == 'Normal'"
      },
      {
        "key": "alt+k",
        "command": "editor.action.moveLinesUpAction",
        "when": "editorTextFocus && vim.active && vim.mode == 'Normal'"
      },
      {
        "key": "alt+shift+k",
        "command": "editor.action.copyLinesUpAction",
        "when": "editorTextFocus && vim.active && vim.mode == 'Normal'"
      },
    ]

现在我们可以在VSCode中使用这些vim友好的命令了!

Alt + J向下移动一行 Alt + K向上移动一行 Shift + Alt + J复制一行 Shift + Alt + K复制一行

根据操作系统的不同,可以使用以下方法:

窗口:

帽子Shift + Alt +↓还是是Shift + Alt +↑。

Mac:

Shift +Option +↓或Shift +Option +↑

另外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"
}