Reputation: 3501
I'm looking to switch between terminals open in visual studio code.
With this "Switch focus between editor and integrated terminal in Visual Studio Code" question I correctly setup the focus, but I would like to switch between terminals, not only from code to terminal.
Is there a way to do it?
Upvotes: 253
Views: 131785
Reputation: 9011
Windows and Linux
Alt + ◄
or
Alt + ►
(Alt + Left Arrow or Alt + Right Arrow)
Mac Os
⌘ + ⌥ + ◄
or
⌘ + ⌥ + ►
(Cmd + Option + Left Arrow or Cmd + Option + Right Arrow)
Further reading: Vscode key bindings.
Upvotes: 2
Reputation: 11
For MacOS to navigate between splited terminals:
⌥⌘← Previous pane
⌥⌘→ Next pane
Upvotes: 1
Reputation: 191
For me, the existing bindings ctrl+`
to focus on the terminal panel when in the editor and ctrl+shift+\
to focus on the terminal tabs panel and following custom keybinding ctrl+shift+\
to focus back to the terminal panel when I am on the terminal tab panel, are just enough to skip completely mouse/touchpad while using the vscode.
{
"key": "ctrl+shift+\\",
"command": "terminal.focus",
"when": "terminalHasBeenCreated && terminalTabsFocus && !terminalFocus || terminalProcessSupported && terminalTabsFocus && !terminalFocus"
}
Upvotes: 0
Reputation: 1
For MacOs
Move to left terminal - Cmd + Option + LeftArrow
Move to right terminal - Cmd + Option + RightArrow
Move to previous terminal - Ctrl+PageUp (macOS Cmd+Shift+])
Move to next terminal - Ctrl+PageDown (macOS Cmd+shift+[)
Focus terminal tabs view - Ctrl+Shift+\ (macOS Cmd+Shift+)
Upvotes: 0
Reputation: 51
Steps:
On windows ⊞ Win
[
{
"key": "ctrl+win+down",
"command": "workbench.action.terminal.focusNext",
"when": "editorIsOpen && terminalHasBeenCreated && terminalIsOpen || terminalFocus && terminalIsOpen && terminalProcessSupported"
},
{
"key": "ctrl+win+up",
"command": "workbench.action.terminal.focusPrevious",
"when": "editorIsOpen && terminalHasBeenCreated && terminalIsOpen || terminalFocus && terminalIsOpen && terminalProcessSupported"
}
]
On Linux Meta
[
{
"key": "ctrl+meta+down",
"command": "workbench.action.terminal.focusNext",
"when": "editorIsOpen && terminalHasBeenCreated && terminalIsOpen || terminalFocus && terminalIsOpen && terminalProcessSupported"
},
{
"key": "ctrl+meta+up",
"command": "workbench.action.terminal.focusPrevious",
"when": "editorIsOpen && terminalHasBeenCreated && terminalIsOpen || terminalFocus && terminalIsOpen && terminalProcessSupported"
}
]
This settings allows you to switch terminals without having the focus on terminal
Note: You can custom your keyboard shortcut as you want
Upvotes: 5
Reputation: 7323
If anyone else is so used to switching between tabs with ⌘+[0-9] this mapping in your keybindings.json
might useful:
{
"key": "cmd+1",
"command": "workbench.action.terminal.focusAtIndex1",
"when": "terminalFocus"
},
{
"key": "cmd+2",
"command": "workbench.action.terminal.focusAtIndex2",
"when": "terminalFocus"
},
{
"key": "cmd+3",
"command": "workbench.action.terminal.focusAtIndex3",
"when": "terminalFocus"
},
You can also extend the conditional in case you're using the terminal editor (to avoid switching when focused).
{
"key": "cmd+1",
"command": "workbench.action.terminal.focusAtIndex1",
"when": "terminalFocus && !terminalEditorFocus"
},
Upvotes: 3
Reputation: 1341
In current version of VSCode it is available like this. You can search this command in the Keyboard Shortcuts
workbench.action.terminal.focusNext
workbench.action.terminal.focusPrevious
Upvotes: 1
Reputation: 163
I have been trying to find the same shortcut, I found with VS code what helps is to know how the different UI components and actions are called.
In this case once "Keyboard Shortcuts" tab (where you can view and customize shortcuts) is open search for "prev terminal group" or "next terminal group".
We can see that VS Code has default shortcuts for:
See results for my search:
I am not sure which one you are the most interested in but, try each and once you found the shortcut you were looking for: use it or customize it to your likings.
Hope that helps 🙏
Upvotes: 0
Reputation: 355
I've got Ctrl+PageDown
/Ctrl+PageUp
in my IDE Keyboard Shortcut settings, which I believe is the default as I didn't change them.
To figure out the shortcuts on your machine, go to File>Preferences>Keyboard Shortcuts and in the search box paste workbench.action.terminal.focusNext
or workbench.action.terminal.focusPrevious
This would only switch between terminal groups. So if 2 terminals were in the same group (that is there were split to display side-by-side), it wouldn't switch between those. To switch between terminals in the same group, use "Alt+LeftArrow" or "Alt+RightArrow".
Credits to @Victory Ifebhor for the side-by-side case, clarified in the comments.
Upvotes: 8
Reputation: 763
I believe the answer you are looking for is Cmd
+Shift
+[
(and Cmd
+Shift
+]
)
Upvotes: 9
Reputation: 195
Pay attention to the the VS Code concept of Group, as that can trip you up when reading some of the answers here.
i.e there are different default shortcuts to switch between terminals in the same group (CMD+OPT+up/down) or between different terminal groups (SHIFT+CMD+[ / ])
Upvotes: 4
Reputation: 41
You can set up an easy custom keyboard shortcut in Vs Code for this
Now you can switch to focus on the sidebar terminal without using your mouse but if you just want to switch to the main terminal Ctrl+J
Upvotes: 1
Reputation: 507
On Windows 10 (not sure about Linux and Mac):
To switch between split terminal windows in Visual Studio Code use
Alt + Right arrow / Left arrow
Upvotes: 19
Reputation: 10482
alt
+ up/down left/right arrows
to switch between splitted terminals.
If alt
unfocuses your terminal and focuses the menu, add this to the settings file
// settings.json
"window.titleBarStyle": "custom",
"window.customMenuBarAltFocus": false
Upvotes: 64
Reputation: 4542
As of Release 1.56.0, there is inbuilt support for switching terminals in VS Code:
New keybindings
The terminal has several new default keybindings this release:
- Move to previous terminal -
Ctrl+PageUp (macOS Cmd+Shift+])
- Move to next terminal -
Ctrl+PageDown (macOS Cmd+shift+[)
- Focus terminal tabs view -
Ctrl+Shift+\ (macOS Cmd+Shift+\)
- Terminal tabs previewAs always, these default keybindings can be removed or custom keybindings can be added via the keybindings system.
Upvotes: 238
Reputation: 4090
On Windows
to switch terminal ctrl
+ ~
to switch back to code editor ctrl
+ 1
Upvotes: 17
Reputation: 692
Improving on @Serhii Popov's answer
Use up and down instead of pageup and pagedown
Go to File
→ Preferences
→ Keyboard Shortcuts
or just press Ctrl + k + Ctrl + s.
Then click the icon in upper right corner to open the keybindings.json file:
Then add the objects below to the array in the file:
[
...
{
"key": "ctrl+down",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
},
{
"key": "ctrl+up",
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus"
}
...
]
Note: On Mac change ctrl
to cmd
Upvotes: 38
Reputation: 3804
Go to File → Preferences → Keyboard Shortcuts or just press Ctrl + k + Ctrl + s.
Then click the icon in upper right corner, it opens keybindings.json
file:
Try adding the following two entries to this file:
{
"key": "ctrl+pagedown",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
},
{
"key": "ctrl+pageup",
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus"
}
Note: On Mac change ctrl to cmd
Upvotes: 182
Reputation: 2608
Here is my approach, which provides a consistent way of navigating between active terminals as well as jumping between the terminal and editor panes. 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 <arrow direction>
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 (note that moving between on-screen split terminals is done with ctrl+x left
or ctrl+x right
).
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"
},
This is a work in progress as I'm trying to mimic my emacs behavior in VS Code, but some key elements are missing, like being able to navigate to a terminal buffer by name (without using a mouse/dropdown). Overall I'm pretty surprised by the poor editor group/pane navigation UX in an otherwise amazing product, but working on getting used to it.
Upvotes: 4
Reputation: 3501
Looking deeply I found it:
{
"key": "shift+cmd+]",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
}
:)
Upvotes: 79