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


当前回答

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

其他回答

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

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

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

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

另一种选择是使用F6和shift+F6。

F6点击“聚焦下一部分”,将焦点从编辑器移动到下面的面板(终端、输出、调试控制台等)。

shift+F6点击“聚焦前一部分”,将焦点从终端面板移回编辑器。

与ctrl + '相比,this的优势在于:

它不隐藏终端/面板(如果这是你喜欢的。如果您喜欢隐藏/取消隐藏终端,那么只需使用ctrl + ')。 这将适用于任何面板(终端,输出,调试控制台等)。

Control + '~'将用于在两者之间切换。' "就在标签按钮的上方。 这个快捷方式只能在mac中使用。

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

嘿,我的工作步骤是:

CTRL + shift+ p,寻找首选项:键盘快捷键

或者你可以使用CTRL k + CTRL s直接打开它

在搜索框中寻找终端:焦点终端,我为自己设置了alt + T alt + T,但你可以选择你想要的组合 在搜索框中搜索“视图:焦点活动编辑器组”,为自己设置alt + E alt + E,但同样你可以选择你想要的组合

就是这样,我希望这对你有所帮助