Is there a quick change tabs function in Visual Studio Code?
Visual Studio-CodeVscode SettingsVisual Studio-Code Problem Overview
The current function of giving me a dropdown option of which tab to choose is just so annoying. Is there a possibility to remove it so the tabs would work like in some modern web browser.
Visual Studio-Code Solutions
Solution 1 - Visual Studio-Code
By default, Ctrl+Tab in Visual Studio Code cycles through tabs in order of most recently used. This is confusing because it depends on hidden state.
Web browsers cycle through tabs in visible order. This is much more intuitive.
To achieve this in Visual Studio Code, you have to edit keybindings.json
. Use the Command Palette with CTRL+SHIFT+P, enter "Preferences: Open Keyboard Shortcuts (JSON)", and hit Enter.
Then add to the end of the file:
[
// ...
{
"key": "ctrl+tab",
"command": "workbench.action.nextEditor"
},
{
"key": "ctrl+shift+tab",
"command": "workbench.action.previousEditor"
}
]
Alternatively, to only cycle through tabs of the current window/split view, you can use:
[ { "key": "ctrl+tab", "command": "workbench.action.nextEditorInGroup" }, { "key": "ctrl+shift+tab", "command": "workbench.action.previousEditorInGroup" }]
Alternatively, you can use Ctrl+PageDown (Windows) or Cmd+Option+Right (Mac).
Solution 2 - Visual Studio-Code
@Combii I found a way to swap
CMD+1, CMD+2, CMD+3 with CTRL+1, CTRL+2, CTRL+3, ...
In macOS, go to:
> Code > Preferences > Keyboard Shortcuts
On that page, click the button on the top right of the page...
and append the configuration below, then save.
[ { "key": "cmd+0", "command": "workbench.action.openLastEditorInGroup" }, { "key": "cmd+1", "command": "workbench.action.openEditorAtIndex1" }, { "key": "cmd+2", "command": "workbench.action.openEditorAtIndex2" }, { "key": "cmd+3", "command": "workbench.action.openEditorAtIndex3" }, { "key": "cmd+4", "command": "workbench.action.openEditorAtIndex4" }, { "key": "cmd+5", "command": "workbench.action.openEditorAtIndex5" }, { "key": "cmd+6", "command": "workbench.action.openEditorAtIndex6" }, { "key": "cmd+7", "command": "workbench.action.openEditorAtIndex7" }, { "key": "cmd+8", "command": "workbench.action.openEditorAtIndex8" }, { "key": "cmd+9", "command": "workbench.action.openEditorAtIndex9" }, { "key": "ctrl+1", "command": "workbench.action.focusFirstEditorGroup" }, { "key": "ctrl+2", "command": "workbench.action.focusSecondEditorGroup" }, { "key": "ctrl+3", "command": "workbench.action.focusThirdEditorGroup" }]
You now can use CMD+[1-9] to switch between tabs and CTRL+[1-3] to focus editor groups! Hope this answer is helpful.
Solution 3 - Visual Studio-Code
Windows
When using Visual Studio Code on Windows, you can use CTRL + PAGE_UP
to switch to the previous tab, and CTRL + PAGE_DN
to switch to the next tab.
You also have the ability to switch to tabs based on their (non-zero relative) index. You can do so, by pressing and holding ALT
, followed by a number (1 through 9).
macOS
To quickly navigate between tabs, press and hold the CMD
key, followed by the number (1 through 9) of the tab you want to switch to.
You also have the ability to switch between the previous/next tab via the CMD + ALT + LEFT/RIGHT
keyboard shortcut.
Please note that in order to switch to a tab that is in a different editor group, you must first switch to the desired editor group.
Pro Tip: If you aren't comfortable with any of the key bindings, you can change them to whatever you feel more comfortable with!
Solution 4 - Visual Studio-Code
Mac OS
Prev tab: Shift + Cmd + [
Next Tab: Shift + Cmd + ]
Mac OS (alternative)
Prev tab: Cmnd + Alt + ←
Next Tab: Cmnd + Alt + →
Windows:
Prev tab: Ctrl + Shift + Tab
Next tab: Ctrl + Tab
Linux / Windows (alternative):
Prev tab: Ctrl + Page Down
Next tab: Ctrl + Page Up
Solution 5 - Visual Studio-Code
If you are using the VSCodeVim
extension, you can use the Vim key shortcuts:
> Next tab: gt > > Prior tab: gT > > Numbered tab: nnngt
Solution 6 - Visual Studio-Code
macOS - revised 2017
IN 2017, the VS CODE keyboard shortcuts have changed to CTRL+1, CTRL+2,CTRL+3 etc..to switch between tabs.
CMD+1, CMD+2, and CMD+3
switch between and create tab groups
Solution 7 - Visual Studio-Code
Windows
previous
Ctrl + Shift + Tab
Next
Ctrl + Tab
Mac OS
previous
Shift+ Cmd + [
Next
Shift + Cmd + ]
Solution 8 - Visual Studio-Code
Better approch is use alt+right and alt+left keys to navigate like Jetbrains IDE Webstorm does
Here is my config. it also include create new file and folder
{
"key": "ctrl+n",
"command": "explorer.newFile"
},
{
"key": "ctrl+shift+n",
"command": "explorer.newFolder"
},
{
"key": "alt+left",
"command": "workbench.action.previousEditor"
},
{
"key": "alt+right",
"command": "workbench.action.nextEditor"
}
Solution 9 - Visual Studio-Code
Visual Studio Code v1.35.0 let's you set the (Ctrl+Tab) / (Shift+Ctrl+Tab) key sequences to sequentially switch between editors by binding those keys sequences to the commands "View: Open Next Editor" and "View: Open Previous Editor", respectively.
On macOS:
- Navigate to: Code > Preferences > Keyboard Shortcuts
- Search or navigate down to the following two options:
- View: Open Next Editor
- View: Open Previous Editor
- Change both keybindings to the desired key sequence.
- View: Open Next Editor -> (Ctrl+Tab)
- View: Open Previous Editor -> (Shift+Ctrl+Tab)
- You will likely run into a conflicting binding. If so, take note of the command and reassign or remove the existing key binding.
If you mess up, you can always revert back to the default state for a given binding by right-clicking on any keybinding and selecting "Reset Keybinding".
Solution 10 - Visual Studio-Code
for linux... I use ctrl+pageUp or pageDown
Solution 11 - Visual Studio-Code
Linux key-map to match the browser:
[ { "key": "ctrl+0", "command": "workbench.action.lastEditorInGroup" }, { "key": "ctrl+1", "command": "workbench.action.openEditorAtIndex1" }, { "key": "ctrl+2", "command": "workbench.action.openEditorAtIndex2" }, { "key": "ctrl+3", "command": "workbench.action.openEditorAtIndex3" }, { "key": "ctrl+4", "command": "workbench.action.openEditorAtIndex4" }, { "key": "ctrl+5", "command": "workbench.action.openEditorAtIndex5" }, { "key": "ctrl+6", "command": "workbench.action.openEditorAtIndex6" }, { "key": "ctrl+7", "command": "workbench.action.openEditorAtIndex7" }, { "key": "ctrl+8", "command": "workbench.action.openEditorAtIndex8" }, { "key": "ctrl+9", "command": "workbench.action.openEditorAtIndex9" }, { "key": "alt+1", "command": "workbench.action.focusFirstEditorGroup" }, { "key": "alt+2", "command": "workbench.action.focusSecondEditorGroup" }, { "key": "alt+3", "command": "workbench.action.focusThirdEditorGroup" }]
Solution 12 - Visual Studio-Code
Another way to quickly change tabs would be in VSCode 1.45 (April 2020)
> ## Switch tabs using mouse wheel
>
> When you use the mouse wheel to scroll over editor tabs, you can currently not switch to the tab, only reveal tabs that are out of view.
>
> Now with a new setting workbench.editor.scrollToSwitchTabs
this behaviour can be changed if you change it to true
.
>
>
>
> Note: you can also press and hold the Shift key while scrolling to get the opposite behaviour (i.e. you can switch to tabs even with this setting being turned off).
Solution 13 - Visual Studio-Code
> When using Visual Studio Code on Linux/Windows, you can use CTRL + PAGE_UP to switch to the previous tab, and CTRL + PAGE_DN to switch to the next tab. You also have the ability to switch to tabs based on their (non-zero relative) index. You can do so, by pressing and holding ALT , followed by a number (1 through 9).
For more details: check here
Solution 14 - Visual Studio-Code
This also works on MAC OS:
Press for select specific Tab: Control + 1 or Control 2, Control 3, etc.
Press for show/select all posible Tabs: Control + Tab.
Solution 15 - Visual Studio-Code
I find it really annoying that CTRL+TAB and CTRL+SHIFT+TAB only cycle through the open files in a panel (instead of all panels) when I have windows split in multiple panels. To change the behaviour so that it cycles through all panels while retaining the behaviour once inside of the quick open dialog, add these to your keybindings:
{
"key": "ctrl+tab",
"command": "workbench.action.quickOpenPreviousRecentlyUsedEditor"
},
{
"key": "ctrl+shift+tab",
"command": "workbench.action.quickOpenLeastRecentlyUsedEditor"
},
{
"key": "ctrl+tab",
"command": "workbench.action.quickOpenNavigateNextInEditorPicker",
"when": "inEditorsPicker && inQuickOpen"
},
{
"key": "ctrl+shift+tab",
"command": "workbench.action.quickOpenNavigatePreviousInEditorPicker",
"when": "inEditorsPicker && inQuickOpen"
}
Solution 16 - Visual Studio-Code
There are multiple ways through which you would can toggle the tabs.
- Modern browser way based on position.
{
"key": "ctrl+tab",
"command": "workbench.action.nextEditor"
},
{
"key": "ctrl+shift+tab",
"command": "workbench.action.previousEditor"
}
- Recently sorted
{
"key": "ctrl+shift+tab",
"command": "workbench.action.openNextRecentlyUsedEditor"
},
{
"key": "ctrl+tab",
"command": "workbench.action.openPreviousRecentlyUsedEditor"
}
Solution 17 - Visual Studio-Code
Vim users might find these key bindings natural for switching between groups and windows within groups:
{ "key": "ctrl+j", "command": "workbench.action.nextEditorInGroup" },
{ "key": "ctrl+k", "command": "workbench.action.previousEditorInGroup" },
{ "key": "ctrl+h", "command": "workbench.action.focusPreviousGroup" },
{ "key": "ctrl+l", "command": "workbench.action.focusNextGroup" }
See this answer if you want to include the terminal when cycling between editors groups
Solution 18 - Visual Studio-Code
Linux In current Vscode 1.44.1 version
we could use ctrl+pageup for next editor and ctrl+pagedown for previous editor.
If there is a need to change
ctrl+shift+p > Preferences:Open Keyboard Shortcuts.
search for
nextEditor
change if needed by clicking it.
Solution 19 - Visual Studio-Code
@SC_Chupacabra has correct answer for modifying behavior.
I generally prefer CTRL + PAGE UP / DOWN for my navigation, rather than using the TAB key.
{
"key": "ctrl+pageUp",
"command": "workbench.action.nextEditor"
},
{
"key": "ctrl+pageDown",
"command": "workbench.action.previousEditor"
}
Solution 20 - Visual Studio-Code
I'm using this script for AutoHotKey
^+WheelUp::
WinGetActiveTitle, originalWindow
WinActivate, ahk_exe Code.exe
Send ^{PgDn}
WinActivate, %originalWindow%
return
This lets me hold control + shift and use my scroll wheel to move between VSCode tabs even with another program focused. I use something similar for browser tabs and video control.
Solution 21 - Visual Studio-Code
you can just do the following:
1.) open vscode.
2.) press ctrl+k+s (press in order as written).
3.) type in the search bar
the following: nextEditorInGroup
press on the first incoming and Keybind it (by 2 pressed) to alt+->(right errow).
4.) do the same for nextEditorInGroup
and Keybind it to alt+<-(left errow).
5.) now you can pass around the tabs by alt+left or alt+right!
Solution 22 - Visual Studio-Code
Use Sublime Text Keymaps. So much more intuitive.
⌘k⌘m
Import Sublime Text Keymaps:
Name: Sublime Text Keymap and Settings Importer
Id: ms-vscode.sublime-keybindings
Description: Import Sublime Text settings and keybindings into VS Code.
Version: 4.0.3
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode.sublime-keybindings
Solution 23 - Visual Studio-Code
I couldn't find a post for VS Community, so I'll post my solution here.
First, you need to go to Tools -> Options -> Environment -> Keyboard, then find the command
Window.NextTab
. Near the bottom it should say "Use new shortcut in: ". Set that to Global (should be default), then select the textbox to the right and hit Ctrl + Tab. Remove all current shortcuts for the selected command, and hit Assign. For Ctrl + Shift + Tab, the command should be Window.PreviousTab
.
Hope this helps :) If there's a separate post for VS Community, I'd gladly move this post over.