使用微软的Visual Studio Code,我如何复制一行代码,然后上下移动它?(类似于Sublime的cmd+shift+d行为)
这是一个我经常使用的特性,如果没有它,我很难使用Visual Studio Code。
使用微软的Visual Studio Code,我如何复制一行代码,然后上下移动它?(类似于Sublime的cmd+shift+d行为)
这是一个我经常使用的特性,如果没有它,我很难使用Visual Studio Code。
当前回答
你可以找到快捷键
文件>首选项>键盘快捷方式
默认的快捷键是,
向下复制行动作:shift+alt+向下
动作:shift+alt+向上
移动队列动作:alt+向上
向下移动线条动作:alt+向下
或者你可以覆盖键盘快捷键从
文件>首选项>键盘快捷方式
编辑keybindings.json
例子:
[
{
"key": "ctrl+d",
"command": "editor.action.copyLinesDownAction",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+up",
"command": "editor.action.moveLinesUpAction",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+down",
"command": "editor.action.moveLinesDownAction",
"when": "editorTextFocus"
}
]
其他回答
ALT + SHIFT +上/下试试
这对我很管用!
你可以找到快捷键
文件>首选项>键盘快捷方式
默认的快捷键是,
向下复制行动作:shift+alt+向下
动作:shift+alt+向上
移动队列动作:alt+向上
向下移动线条动作:alt+向下
或者你可以覆盖键盘快捷键从
文件>首选项>键盘快捷方式
编辑keybindings.json
例子:
[
{
"key": "ctrl+d",
"command": "editor.action.copyLinesDownAction",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+up",
"command": "editor.action.moveLinesUpAction",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+down",
"command": "editor.action.moveLinesDownAction",
"when": "editorTextFocus"
}
]
只需转到文件->首选项->键盘快捷键 在那里你可以更改任何你喜欢的快捷方式。搜索重复的内容,并将其更改为您在其他编辑器中经常使用的内容。我改为Ctrl+D
你要找的命令是editor.action.copyLinesDownAction和editor.action.copyLinesUpAction。
您可以通过选择文件>首选项>键盘快捷键来查看相关的键绑定
窗口:
Shift+Alt+下和Shift+Alt+上
Mac:
Shift+Option+Down和Shift+OptionUp
Linux:
Ctrl+Shift+Alt+Down和Ctrl+Shift+Alt+Up
(可能需要使用numpad向下和向上的Linux)
此外,命令editor.action.moveLinesUpAction和editor.action.moveLinesDownAction是移动行,它们在Windows和Mac上绑定为Alt+Down和Alt+Up,在Linux上绑定为Ctrl+Down和Ctrl+Up。
如果你来自Sublime Text,不想重新学习新的键绑定,你可以使用Visual Code Studio的这个扩展。
Sublime Text Keymap for VS Code 这个扩展端口最流行的Sublime文本键盘快捷键到Visual Studio代码。安装扩展和重新启动VS Code你最喜欢的键盘快捷方式从Sublime文本现在可用。
https://marketplace.visualstudio.com/items?itemName=ms-vscode.sublime-keybindings