有人知道在Visual Studio Code中切换编辑器和集成终端的快捷键(Mac和Linux)吗?


当前回答

ctrl+ ':专注于集成终端

ctrl+1:聚焦编辑器(如果Editor -2命令是ctrl+2)

更多信息:https://medium.com/p/21969576c09c

其他回答

100%工作设置…

[
    { "key": "alt+right", "command": "workbench.action.terminal.focus"},
    { "key": "alt+left", "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus"}   
]

从编辑器切换到 终端。workbench.action.focusActiveEditorGroup:切换 从终端到编辑器。

根据VS Code键盘快捷键文档页,切换集成终端的默认键绑定是“Ctrl+ '”。如果你不喜欢这个快捷方式,你可以在你的键绑定文件中添加类似的东西来改变它:

{ "key": "ctrl+l", "command": "workbench.action.terminal.toggleTerminal" }

似乎没有一个默认的键绑定来简单地聚焦底部面板。所以,如果你不想切换底部面板,你需要在你的keybindings文件中添加类似以下内容:

{ "key": "ctrl+t", "command": "workbench.action.focusPanel" }

为了在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"
}
]

使用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"
},

这不是确切的问题,但我发现它非常有用和相关。

如果有人想从一个终端切换到另一个终端,也可以在Visual Studio的集成终端面板中打开,您可以搜索:

终端:关注下一个终端

或者添加以下快捷键,用键盘组合更快。

  {
    "key": "alt+cmd+right",
    "command": "workbench.action.terminal.focusNext",
    "when": "terminalFocus"
  },
  {
    "key": "alt+cmd+left",
    "command": "workbench.action.terminal.focusPrevious",
    "when": "terminalFocus"
  },