I just started using VSCode and I'm looking for a way of, while having both the code open and the terminal(the one inside VSCode), switch between typing on these parts of the editor with a shortcut. Looked around the web but the best I could find would be to close and open the terminal.

Any ideas how to do this?


I found bit hard to press ctrl+`. It also close the terminal when we press ctrl + '

So, I configured mine as following:

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

Step to configure:

  1. Go to: File > Preferences > keyboard shortcuts
  2. then in the search-bar search for "focus terminal"
  3. select "workbench.action.terminal.focus" and then ctrl + k or press your custom key and then press enter.
  4. Similarly, in the search-bar search for "focus active editor group
  5. select "workbench.action.focusActiveEditorGroup" and then press ctrl + j or press your custom key and then press enter.

After the above setup:

  • Press ctrl + k to focus cursor on terminal
  • Press ctrl + j to focus cursor on coding section without closing terminal
| improve this answer | |
  • Great answer, I opted for the Intellij/IDEA settings of ctrl + tab + ctrl + t. Thanks for making this easy to follow +1. – binarygiant Oct 24 '18 at 18:58
  • the "when" condition should be reversed. It should be "when": "!terminalFocus" for Ctrl-K – Igor Bukanov Dec 13 '18 at 13:47
  • I prefer to flip the keybinds so ctrl+j goes down to the terminal which is similar to my vim keybinds for switching windows, which is similar to vim's natural movement keybinds. ctrl+k goes up to the code for the same reasons. I also left off the when condition since it's not really needed in my case. – Cameron Gagnon Feb 12 at 6:37
  • Doesn't this kill the two-part keybindings that rely on first pressing ctrl+k? – Aspiring Dev Apr 21 at 21:43

Refer to this Question/Answers Switch focus between editor and integrated terminal in Visual Studio Code on Stackoverflow, I think @Trav L answer might be closed one. But need to config a little bit more.

VS Code v1.26.1 as a base version

  1. Open keyboard shortcut editor from menu File->Preferences->Keyboard Shortcuts (Ctrl+K Ctrl+S)
  2. Click on the link keybindings.json above the screen.
  3. Overwrite your custom keyboard shortcuts on the right side panel, the keybindings.json file will store in your <user dir>\AppData\Roaming\Code\User. With this values you can overloading the key shortcut with using when keyword like code below.

Credit: @wgj user of Stackoverflow

// Toggle between terminal and editor focus
{ "key": "ctrl+`", "command": "workbench.action.terminal.focus"},
{ "key": "ctrl+`", "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus"}
  1. Now you can toggle cursor position by press the same key Ctrl+`, VS Code will recognize base by situation where the cursor is.

Special 1

Use Settings Sync extension for saving your custom key binding and others to your secret GIST (Github), for switching between workstation, it's recommended from me. It's quite convenient for me.

Special 2

Some time I need to kill the terminal pane for get the whole code area screen. So I also setting this to keybindings.json. The result is equal to clicking on the X mark of the terminal pane. (Just change to your favorite key if you would like to)

{ "key": "ctrl+k ctrl+`", "command": "workbench.action.terminal.kill" },

| improve this answer | |

Here is how to have the same hotkey to switch back and forth from code to terminal for maximum productivity:

        "key": "f1",
        "command": "workbench.action.focusActiveEditorGroup",
        "when": "terminalFocus"
        "key": "f1",
        "command": "workbench.action.terminal.focusNext",
        "when": "!terminalFocus"
| improve this answer | |

Generally VS Code uses ctrl+j to open Terminal so I created a keybinding to switch with ctrl+k combination, like below at keybindings.json:

    "key": "ctrl+k",
    "command": "workbench.action.terminal.focus"
    "key": "ctrl+k",
    "command": "workbench.action.focusActiveEditorGroup",
    "when": "terminalFocus"
| improve this answer | |

You do this by setting the keybindings for Focus Terminal and Focus Active Editor Group. These two will allow you to switch the focus between the Editor and the Terminal, without having to just close the terminal.

The other positive is if you perform some action that causes another panel to open such as Output or Problems. Using the keystroke for the editor group will change your focus back to the editor.

I can't say what these are by default because I set this long ago in Code. As you can see from the screenshot below I set them to the same keybinding: ctrl + shift + i.

This makes them act as a toggle switch so it takes the focus back and forth. You can basically just hold down ctrl + shift, then hitting i will move your focus back and forth.

enter image description here

| improve this answer | |

If you want Ctrl+` to toggle between terminal and the text editor, then do the following:

  1. Open your keybinding.json file: Ctrl+Shift+P then select Preferences: Open Keyboard Shortcuts (JSON).

  2. Add the following line:

  { "key": "ctrl+`", "command": "workbench.action.terminal.toggleTerminal" },
  1. Save and close keybinding.json file.
| improve this answer | |

Toggle Integrated Terminal

Ctrl + `

This will turns on/off terminal viewport while switches your cursor back and forth between editor and terminal.

| improve this answer | |
  • 1
    OP specifically stated: "the best I could find would be to close and open the terminal." – user94184 Jan 14 '18 at 6:47

I see you already got some options, but I wanted to add the method I use.

Press CTRL + SHIFT + p
Write 'view terminal'
Command palette should now show: View: Toggle Integrated Terminal

Now you can use CTRL + SHIFT + p followed by ENTER to toggle between terminal and the text editor as long as that command is the last used in the command palette.

This option will hide the terminal when you go back to the editor.

An alternative that only shifts focus and keeps terminal visible is here:

View: Focus First Editor Group
Terminal: Focus Terminal

Also found in the command palette.

I know they are not direct shortcuts, but I find the command palette easy to work with, since I have the commands I often use a few clicks away by using the down arrow.

| improve this answer | |
  • What is Ctrl+Shift+P supposed to do? Does nothing for me with default keybindings. – bugybunny Oct 9 '18 at 9:33
  • Command Palette# VS Code is equally accessible from the keyboard. The most important key combination to know is Ctrl+Shift+P, which brings up the Command Palette. From here, you have access to all of the functionality of VS Code, including keyboard shortcuts for the most common operations. – anders Oct 10 '18 at 12:50
  • Oh, I wasn‘t in VSCode but in Visual Studio Professional which is something different. Nvm – bugybunny Oct 10 '18 at 13:39

There is no default shortcut for switching between terminal and editor in VScode. But you can add USER shortcut in the Settings > Keyboard Shortcuts.

Note:- I have placed "Altr + Ctrl + ," for Editor Focus and "Altr + Ctrl + ." for Terminal Focus as shortcuts, as they are not used by any other tasks and are easy to reach.

In Keyboard Shortcuts, type Focus Active Editor Group and DOUBLE CLICK the option and create your own shortcut and press ENTER.

In Keyboard Shortcuts, type Terminal: focus terminal action and find the option exactly we have written above i.e. "Terminal: focus terminal action" and create your own shortcut and press ENTER

There are many similar options related to terminal focus like previous terminal, next terminal etc but they already have shortcuts, so it would be easy to find it.

Well, i have provided the method for windows, And i am not sure about IOS and LINUX, But I think it will work.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.