Switch focus between editor and integrated terminal in Visual Studio Code

前端 未结 16 1692
我寻月下人不归
我寻月下人不归 2020-12-04 04:07

Does anyone know the keyboard shortcut (Mac and Linux) to switch the focus between editor and integrated terminal in Visual Studio Code?

16条回答
  •  忘掉有多难
    2020-12-04 04:48

    Here is my approach, which provides a consistent way of navigating between active terminals as well as jumping between the terminal and editor panes without closing the terminal view. You can try adding this to your keybindings.json directly but I would recommend you go through the keybinding UI (cmd+K cmd+S on a Mac) so you can review/manage conflicts etc.

    With this I can use ctrl+x to navigate to any visible editor or terminal. Once the cursor is in the terminal section you can use ctrl+x ctrl+up or ctrl+x ctrl+down to cycle through the active terminals.

    cmd-J is still used to hide/show the terminal pane.

        {
            "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"
        },
    

提交回复
热议问题