有人知道在Visual Studio Code中,Mac和Linux系统下在编辑器和集成终端之间切换焦点的键盘快捷键吗?
有人知道在Visual Studio Code中,Mac和Linux系统下在编辑器和集成终端之间切换焦点的键盘快捷键吗?
key
并使用 when
clause 来组合这两个步骤。
您可以通过在keybindings.json
文件中添加适当的设置来实现所需的效果。以下是所需步骤:
打开命令面板(Ctrl+Shift+P Windows/Linux或⇧⌘P Mac)。
键入“Preferences: Open Keyboard Shortcuts (JSON)”,然后按Enter。
将以下条目添加到keybindings.json
文件中:
// Toggle between terminal and editor focus
{
"key": "ctrl+`",
"command": "workbench.action.terminal.focus"
},
{
"key": "ctrl+`",
"command": "workbench.action.focusActiveEditorGroup",
"when": "terminalFocus"
}
这里建议的组合键现在已经作为 VSCode 的默认设置内置(自从版本 1.72.2,或者更早)。在尝试添加之前,请查看是否 ctrl + ` 已经可以使用。
在现代版的 VS Code 中(截至 2022 年),默认键盘快捷键(JSON)文件是只读的,因此对于自定义设置,您需要编辑一个单独的专用文件 keybindings.json
。
更多信息可在官方 Visual Studio 文档页面中找到:
keybindings.json
文件中。 - pseudomarvinCMD-SHIFT-P
-> Preferences: Open Keyboard Shortcuts File
。
另外一个不错的资源:https://code.visualstudio.com/docs/getstarted/keybindings - derFunkCtrl+J 可以使用;但也可以显示/隐藏控制台。
cmd+J 是Mac的快捷键。
{ "key": "cmd+j", "command": "workbench.action.terminal.focus"},
{ "key": "cmd+j", "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus"}
这样我就不必将手从Home Row上移开了。 - ClintmCmd
+J
来聚焦编辑器,而不是使用奇怪的手指瑜伽 Ctrl
+1
。 - sFritsch09我有点晚了,但我已经按照以下方式在keybindings.json
中进行了配置:
{
"key": "ctrl+`",
"command": "workbench.action.terminal.focus",
"when": "editorTextFocus"
},
{
"key": "ctrl+`",
"command": "workbench.action.focusActiveEditorGroup",
"when": "terminalFocus"
},
{
"key": "alt+`",
"command": "workbench.action.terminal.toggleTerminal"
}
我希望有单独的按键来打开/关闭终端和在窗口之间切换焦点。
alt
键比按ctrl
键更容易,因此它们的功能被调换了。 - xjialt
来切换焦点。 - Mr. DuhartF6
和 shift+F6
。
F6
做的是“聚焦下一个部分”,这将使焦点从编辑器移动到下面的面板(终端、输出、调试控制台等)。
shift+F6
做的是“聚焦上一个部分”,这将使焦点从终端面板返回到编辑器。ctrl + `
,这种方法的优点在于:ctrl + `
)。因为我觉得按下ctrl+` 有点困难,所以我将我的配置设置成如下。
{
"key": "ctrl+k",
"command": "workbench.action.focusActiveEditorGroup",
"when": "terminalFocus"
},
{
"key": "ctrl+j",
"command": "workbench.action.terminal.focus",
"when": "!terminalFocus"
}
我还配置了以下内容,以在编辑器组之间移动。
{
"key": "ctrl+h",
"command": "workbench.action.focusPreviousGroup",
"when": "!terminalFocus"
},
{
"key": "ctrl+l",
"command": "workbench.action.focusNextGroup",
"when": "!terminalFocus"
}
顺便说一下,我在 Mac 上通过 系统偏好设置 => 键盘 => 修改键
将 Caps Lock 配置为 ctrl。
嗨,让这个工作的步骤如下:
ctrl + shift+ p
并查找 preferences: keyboard shortcuts
或者您可以使用 ctrl k + ctrl s
直接打开它
在搜索框中查找 Terminal: Focus Terminal
,我为自己设置了 alt + T alt + T
,但您可以选择您想要的组合
在搜索框中查找 View: Focus Active Editor Group
,为自己设置了 alt + E alt + E
,但同样您可以选择您想要的组合
就是这样,希望这可以帮助到您
尝试使用ctrl + `来切换终端的可见性,从而切换焦点。
根据VS Code键盘快捷方式文档页面,“Ctrl+`”是切换集成终端的默认按键绑定。如果你不喜欢这个快捷键,可以通过在键绑定文件中添加类似以下内容来更改它:
{ "key": "ctrl+l", "command": "workbench.action.terminal.toggleTerminal" }
似乎没有默认的按键绑定来仅聚焦于底部面板。因此,如果您不想切换底部面板,则需要将类似以下内容添加到您的按键绑定文件中:
{ "key": "ctrl+t", "command": "workbench.action.focusPanel" }
focusPanel
是针对一般区域(包括像“问题”、“输出”和“调试控制台”之类的内容)。还有一个特别针对集成终端的操作 workbench.action.terminal.focus
。 - wgj将焦点放在集成终端上。然后只需按下Ctrl + 1或
来在编辑器和终端之间切换。 - john-g
ctrl
+ ' ` ' 也能在Windows上完美运行! - Ehtesham ZCTRL
+```的问题在于即使已经存在一个终端,它也会创建一个新的终端。 - Guss