有人知道在Visual Studio Code中切换编辑器和集成终端的快捷键(Mac和Linux)吗?
当前回答
使用keybindings.json中的键绑定:
CTRL+j和CTRL+k将焦点在编辑器组中的编辑器和终端中的终端窗口之间转移 CTRL+h和CTRL+l在包括终端在内的编辑器组之间转移焦点
(这些键绑定对vim用户来说应该特别自然。其他人可能希望把h/j/k/l换成左/下/上/右)
// In an editor group, ctrl+j and ctrl+k jump between editor windows
{ "key": "ctrl+j", "command": "workbench.action.nextEditorInGroup" },
{ "key": "ctrl+k", "command": "workbench.action.previousEditorInGroup" },
// In the terminal, ctrl+j and ctrl+k jump between terminal windows
{
"key": "ctrl+j",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus && terminalHasBeenCreated && !terminalEditorFocus || terminalFocus && terminalProcessSupported && !terminalEditorFocus"
},
{
"key": "ctrl+k",
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus && terminalHasBeenCreated && !terminalEditorFocus || terminalFocus && terminalProcessSupported && !terminalEditorFocus"
},
// In the work area, ctrl+j and ctrl+k jump between editor groups
{ "key": "ctrl+h", "command": "workbench.action.focusPreviousGroup" },
{ "key": "ctrl+l", "command": "workbench.action.focusNextGroup" },
// in the first editor group terminal, jump "back" to the terminal (if there is a terminal open)
{
"key": "ctrl+h",
"when": " terminalHasBeenCreated && terminalIsOpen && activeEditorGroupIndex == 1",
"command": "workbench.action.terminal.focus"
},
// in the last editor group terminal, jump "forward" to the terminal (if there is a terminal open)
{
"key": "ctrl+l",
"when": "terminalHasBeenCreated && terminalIsOpen && activeEditorGroupLast",
"command": "workbench.action.terminal.focus"
},
// in the terminal, jump "back" to the last editor group
{
"key": "ctrl+h",
"command": "workbench.action.focusLastEditorGroup",
"when": "terminalFocus"
},
// in the terminal, jump "forward" to the last first group
{
"key": "ctrl+l",
"command": "workbench.action.focusFirstEditorGroup",
"when": "terminalFocus"
},
其他回答
通常,VS Code使用ctrl+j打开终端,所以我创建了一个键绑定来切换与ctrl+k组合,如下在keybindings.json:
[
{
"key": "ctrl+k",
"command": "workbench.action.terminal.focus"
},
{
"key": "ctrl+k",
"command": "workbench.action.focusActiveEditorGroup",
"when": "terminalFocus"
}
]
适用于任何键盘布局的简单WINDOWS解决方案(可能适用于其他操作系统,但未经测试)
我使用芬兰键盘,所以上面没有一个工作,但这应该适用于所有的键盘。
终端焦点:将鼠标悬停在集成终端的终端文本上。聚焦终端的快捷方式将会弹出-例如,我说CTRL+ö。 编辑器焦点:如上所述,使用CTRL+1。
CTRL + -也可以,这意味着回到以前的光标位置
为了在ctrl+ '组合之间进行切换,我尝试了所有列出的答案,但运气不好。对于那些像我一样有类似问题的人,尝试以下键绑定中的快捷方式。在VSCode 1.59+上测试
[
{
"key": "ctrl+oem_8","command": "workbench.action.terminal.focus", "when": "!terminalFocus"
},
{
"key": "ctrl+oem_8","command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus"
}
]
另一种选择是使用F6和shift+F6。
F6点击“聚焦下一部分”,将焦点从编辑器移动到下面的面板(终端、输出、调试控制台等)。
shift+F6点击“聚焦前一部分”,将焦点从终端面板移回编辑器。
与ctrl + '相比,this的优势在于:
它不隐藏终端/面板(如果这是你喜欢的。如果您喜欢隐藏/取消隐藏终端,那么只需使用ctrl + ')。 这将适用于任何面板(终端,输出,调试控制台等)。
推荐文章
- 如何设置每个文件类型的标签大小?
- 我如何添加环境变量启动。VSCode中的json
- 如何格式化Visual Studio Code项目中的所有文件?
- Pylint在Visual Studio代码中“未解决的导入”错误
- 如何在VS Code中默认打开文本换行
- 在Visual Studio代码中更改突出显示文本的颜色
- Visual studio代码-键盘快捷键-全部展开/折叠
- Visual Studio Code无法检测已安装的Git
- 禁用Visual Studio代码中的工具提示提示
- Visual Studio Code -将空格转换为制表符
- 在VSCode中的列自动硬换行
- Visual Studio Code:格式没有使用缩进设置
- 如何排除文件扩展名和语言从“格式保存”在VSCode?
- Visual Studio代码- URI的目标不存在" package:flutter/material.dart "
- VSCode——如何设置调试Python程序的工作目录