我试图找到在Visual Studio代码中复制一行的快捷方式(我使用1.3.1),我尝试了明显的CTRL + D,但似乎不起作用。
当前回答
另外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"
}
其他回答
根据操作系统的不同,可以使用以下方法:
窗口:
Shift+ Alt + ↓ 或 Shift+ Alt + ↑
Mac:
Shift +Option +↓或Shift +Option +↑
Linux:
Ctrl+Shift+Alt+↓或Ctrl+Shift+Alt+↑
注意:对于一些linux发行版使用Numpad箭头
如果Ubuntu用户仍然想使用↑和↓键而不是另一组键,这个更新可能会帮助他们。
我刚刚在Ubuntu 18.04 LTS上安装了一个新版本的VSCode,上面添加光标和下面添加光标的命令都是重复的
原来的快捷键
我只是删除了使用Ctrl的绑定,并添加了自己的绑定
拷贝顺序
Ctrl + Shift +↑
拷贝行向下
Ctrl + Shift +↓
新快捷键
复制可以通过CTRL+C和CTRL+V实现,光标在行中,没有任何选择。
可以创建仅在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复制一行
另外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"
}
推荐文章
- 打开同一目录两次
- 如何从终端/命令行调用VS代码编辑器
- 如何在Visual Studio代码中重置设置?
- 如何将制表符转换为空格,反之亦然,在现有的文件
- 错误:'types'只能在.ts文件中使用- Visual Studio Code使用@ts-check
- Visual Studio Code: .git文件夹/文件隐藏
- Visual Studio Code:如何调试Python脚本的参数
- 如何在Visual Studio代码中触发参数提示?
- 在VS Code中禁用“Comments are not allowed In JSON”错误
- 使用正则表达式搜索和替换Visual Studio代码
- 如何缩进/格式选择的代码在Visual Studio代码?
- 如何禁用预览文件与点击在vs代码?
- Visual Studio代码更改文件资源管理器托盘的字体大小?
- 如何防止Visual Studio Code总是重新打开以前的文件或文件夹?
- VSCode单引号到双引号自动替换