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


当前回答

下面是一种添加自己的键绑定来切换焦点的方法。

打开VSCode 按Ctrl+Shift+P,搜索键盘快捷键并点击这个(首选项:打开键盘快捷键)。 在搜索面板中搜索“聚焦终端”并找到该选项(终端:聚焦终端视图)并单击加号图标。

输入你喜欢的没有使用的快捷方式,然后按Enter。 进入编辑器模式,尝试使用快捷方式。 现在按Alt+Shift+T进入终端。 想回去找编辑吗?只需按Ctrl+tab

在Windows 10机器上使用VSCode(1.52.1)进行测试

其他回答

ctrl+ ':专注于集成终端

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

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

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

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

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

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

下面是我的方法,它提供了在活动终端之间导航的一致方式,以及在终端和编辑器窗格之间跳转而无需关闭终端视图。您可以尝试将此添加到您的键绑定。我建议你使用键盘绑定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+ '来切换终端的可见性,从而切换焦点。

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

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