Switch focus between editor and integrated terminal in Visual Studio Code

前端 未结 16 1630
我寻月下人不归
我寻月下人不归 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:50

    While there are a lot of modal toggles and navigation shortcuts for VS Code, there isn't one specifically for "move from editor to terminal, and back again". However you can compose the two steps by overloading the key and using the when clause.

    Open the keybindings.json from the editor: CMD-SHIFT-P -> Preferences: Open Keyboard Shortcuts File and add these entries:

    // Toggle between terminal and editor focus
    { "key": "ctrl+`", "command": "workbench.action.terminal.focus"},
    { "key": "ctrl+`", "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus"}
    

    With these shortcuts I will focus between the editor and the Integrated Terminal using the same keystroke.

    0 讨论(0)
  • 2020-12-04 04:51

    control + '~' will work for toggling between the two. and '`' is just above the tab button. This shortcut only works in mac.

    0 讨论(0)
  • 2020-12-04 04:53

    A little late to the game but I configured mine as the following in the 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"
    }
    

    I wanted separate keys for opening/closing terminal and switching focus back and forth between the windows.

    0 讨论(0)
  • 2020-12-04 04:53

    It's not exactly what is asked, but I found it very useful and related.

    If someone wants to change from one terminal to another terminal also open in the integrate terminal panel of Visual Studio, you can search for:

    Terminal: Focus Next Terminal

    Or add the following key shortcut and do it faster with keyboard combination.

      {
        "key": "alt+cmd+right",
        "command": "workbench.action.terminal.focusNext",
        "when": "terminalFocus"
      },
      {
        "key": "alt+cmd+left",
        "command": "workbench.action.terminal.focusPrevious",
        "when": "terminalFocus"
      },
    
    0 讨论(0)
  • 2020-12-04 04:55

    ctrl+` : To Focus on Integrated Terminal

    ctrl+1 : To Focus on Editor (If editor-2 command would be ctrl+2)

    More Info : https://www.rscoder.com/2020/11/14/how-to-switch-focus-between-editor-and-integrated-terminal-in-visual-studio-code/

    0 讨论(0)
  • 2020-12-04 04:57

    I configured mine as following since I found ctrl+` is a bit hard to press.

    {
      "key": "ctrl+k",
      "command": "workbench.action.focusActiveEditorGroup",
      "when": "terminalFocus"
    },
    {
      "key": "ctrl+j",
      "command": "workbench.action.terminal.focus",
      "when": "!terminalFocus"
    }
    

    I also configured the following to move between editor group.

    {
      "key": "ctrl+h",
      "command": "workbench.action.focusPreviousGroup",
      "when": "!terminalFocus"
    },
    {
      "key": "ctrl+l",
      "command": "workbench.action.focusNextGroup",
      "when": "!terminalFocus"
    }
    

    By the way, I configured Caps Lock to ctrl on Mac from the System Preferences => keyboard =>Modifier Keys.

    0 讨论(0)
提交回复
热议问题