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


当前回答

有点晚了,但我在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"
}

我想要单独的键来打开/关闭终端和在窗口之间来回切换焦点。

其他回答

下面是我的方法,它提供了在活动终端之间导航的一致方式,以及在终端和编辑器窗格之间跳转而无需关闭终端视图。您可以尝试将此添加到您的键绑定。我建议你使用键盘绑定UI (Mac上的cmd+K cmd+S),这样你就可以检查/管理冲突等。

这样,我可以使用ctrl+x <箭头方向>导航到任何可见的编辑器或终端。一旦光标在终端部分,您可以使用ctrl+x ctrl+up或ctrl+x ctrl+down在活动终端中循环。

cmd-J仍然用于隐藏/显示终端窗格。

    {
        "key": "ctrl+x right",
        "command": "workbench.action.terminal.focusNextPane",
        "when": "terminalFocus"
    },
    {
        "key": "ctrl+x left",
        "command": "workbench.action.terminal.focusPreviousPane",
        "when": "terminalFocus"
    },
    {
        "key": "ctrl+x ctrl+down",
        "command": "workbench.action.terminal.focusNext",
        "when": "terminalFocus"
    },
    {
        "key": "ctrl+x ctrl+up",
        "command": "workbench.action.terminal.focusPrevious",
        "when": "terminalFocus"
    },
    {
        "key": "ctrl+x up",
        "command": "workbench.action.navigateUp"
    },
    {
        "key": "ctrl+x down",
        "command": "workbench.action.navigateDown"
    },
    {
        "key": "ctrl+x left",
        "command": "workbench.action.navigateLeft",
        "when": "!terminalFocus"
    },
    {
        "key": "ctrl+x right",
        "command": "workbench.action.navigateRight",
        "when": "!terminalFocus"
    },

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

我的解决方案:

只有一把钥匙 如果还没有终端:打开一个终端并聚焦在它上面 如果焦点在终端上:隐藏面板并切换回编辑器 如果焦点在编辑器上并且有一个终端:取消终端窗格并聚焦在它上

  {
    "key": "ctrl+shift+alt+cmd+t",
    "command": "workbench.action.terminal.new",
    "when": "!terminalIsOpen"
  },
  {
    "key": "ctrl+shift+alt+cmd+t",
    "command": "terminal.focus",
    "when": "terminalIsOpen && !terminalFocus"
  },
  {
    "key": "ctrl+shift+alt+cmd+t",
    "command": "workbench.action.closePanel",
    "when": "terminalIsOpen && terminalFocus"
  }

对于版本:1.26.1 (linux),默认情况下没有设置快捷方式。 设置快捷方式

打开键盘快捷键面板[ctrl + k, ctrl + s] 搜索焦点终端

设置快捷方式

编辑器的焦点已默认设置。

有点晚了,但我在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"
}

我想要单独的键来打开/关闭终端和在窗口之间来回切换焦点。