704

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.

Gama11
  • 31,714
  • 9
  • 78
  • 100
yodalr
  • 9,778
  • 10
  • 32
  • 47
  • 78
    I cannot stress out enough how much annoying this is. With VSCode and also other editors. – Avatar Aug 16 '19 at 07:17
  • 5
    What would be even better is if the tabs would always be ordered based on the most recent use. This way the behavior no longer depends on hidden state, but you still have your most used tabs closest at hand without manual sorting. – chtenb Apr 30 '21 at 07:48
  • 2
    @ChieltenBrinke Sounds like a great idea but the tabs will be jumping around I guess which would also make me crazy. But I'd give it a try :D – BonisTech Dec 15 '21 at 11:55
  • 3
    Weird, this is one of the great features of IDEs: how to quickly go back to a recently used tab. For navigating tabs visually, we already have other mappings like ⇧⌘] on macOS for browsers and IDEs. Best to have both options – huyz Nov 30 '22 at 09:51
  • 2
    @huyz It is not best to have a ton of options. You can make the claim that more options provides more flexibility, but that's it. You have the option to walk to the store on your hands, but it isn't the best option. Some options are crap, even if they are valid. The default behavior of the tab function in VS Code is crap. – Anthony Mar 27 '23 at 01:01
  • 1
    Both behaviors are needed for efficient power users. Ctrl-Tab for many IDEs, editors, new browsers like Arc is copying the most-recently used (MRU) behavior that Alt-Tab in Windows (and Cmd-Tab in MacOS) offers. For macOS, the default behavior of Ctrl-Tab in VSCode is fine because we use ⇧⌘] to change tabs so there's no conflict. I think the problem is with Windows users where Ctrl-Tab already has an established meaning. – huyz Mar 27 '23 at 10:40

25 Answers25

1228

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).

Julian Oes
  • 3
  • 1
  • 4
SC_Chupacabra
  • 12,907
  • 1
  • 15
  • 21
  • 8
    Actually it doesn't mimic drop-down behavior. With these keybindings you just navigate tabs to the right (`ctrl+tab`) or to the left (`ctrl+shift+tab`). To navigate tabs based on history use these: `{ "key": "ctrl+tab", "command": "workbench.action.openPreviousRecentlyUsedEditor" }, { "key": "ctrl+shift+tab", "command": "workbench.action.openNextRecentlyUsedEditor" }`. – evenfrost Dec 13 '17 at 09:45
  • 1
    Which is fine only if you don't have tons of files open. MRU or typing the name is the only way after a certain threshhold. – Alan Baljeu Mar 07 '19 at 20:03
  • 1
    the 'keybindings.json' is not available in version 1.35.0 – Pall Arpad Jun 12 '19 at 09:10
  • 14
    May 2021 and now you have to change keybindings via Command Pallet > "Preferences: Open Keyboard Shortcuts" (without the json) which will give you a GUI where you can change keybidings. Editing/saving the JSON does not work anymore. – Empi May 04 '21 at 09:18
  • 1
    I prefer to map `ctrl+pagedown` to `workbench.action.nextEditor` and `ctrl+pageup` to `workbench.action.PreviousEditor` to match tab navigation keys in Chrome, etc. (and maybe cmd+1 thru cmd+9, as below) – gigawatt Feb 08 '22 at 08:35
  • I love god-level answers like these, thank you! – S. Iason Koutsoulis Jul 22 '23 at 15:08
327

@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...

edit keybindings.json button

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.

Kyle Heironimus
  • 7,741
  • 7
  • 39
  • 51
yiyuan lv
  • 3,271
  • 1
  • 8
  • 3
  • 13
    alt+n does this already on windows, I'm sure there is a mac equivalent – Dominic Jan 19 '18 at 09:48
  • 30
    on Mac the equivalent is control+n. I find this to be unintuitive as most programs default to cmd+n for tab navigation. Switching the two behaviours around means you can rely on muscle memory when trying to navigate through your tabs. – Langlois.dev Feb 03 '18 at 21:48
  • I think on mac they just port windows settings with changing command to control for some functions (e.g. switch tab) and didn't port the other (e.g. open and close terminal tab). This is very inconvenient. – Alan May 02 '19 at 22:14
  • 9
    Also, for newest version (Apr2019) you can just search for those items (`workbench.action.openEditorAtIndex1`) and change it. No need to go to `keybindings.json`. – Alan May 02 '19 at 22:18
  • 5
    As of v. 1.38.1 (for OSX), this is outdated. According to [the documentation](https://code.visualstudio.com/docs/getstarted/keybindings#_advanced-customization) go to `Preferences > Keyboard Shortcuts` and then click on the icon on the right of the editor title bar. This will open `keybindings.json`. – Adam_G Sep 16 '19 at 23:37
  • 2
    Yes sir! This is perfect! Been looking all over for the respective solution. – rebellion Oct 26 '20 at 19:15
  • This worked perfectly, could not find a different way on Mac. Thank you! – vstack17 Sep 09 '22 at 02:03
153

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!

Brynden
  • 35,463
  • 2
  • 15
  • 21
  • 4
    CTRL + ALT + LEFT/RIGHT and CTRL + number only copy tabs to new tab group – yodalr Aug 16 '16 at 11:50
  • 4
    The instructions were clear before, it simply does not work on WINDOWS. When I press ctrl+alt+left - nothing happens and when I press ctrl+alt+right it moves the tab into secondary tabs sections on the right. – yodalr Aug 18 '16 at 20:28
  • 5
    @yodalr, on Windows, to cycle between tabs, you press either `CTRL + PAGE_UP` or `CTRL + PAGE_DN`, depending on which way you want to cycle. `CTRL + ALT + LEFT` and `CTRL + ALT + RIGHT` are **not** the keyboard shortcuts I listed for Windows. – Brynden Aug 18 '16 at 23:41
  • 14
    Hmm, it doesn't seem to work as described. On Mac, Cmd + Num switches between tab group (split windows). I want to do that for tabs within the same group. Would I be able to do that? – huggie Mar 26 '17 at 00:46
  • @huggie I'm seeing the same behavior on OSX. Did you find a way to remap this? – tdc May 20 '17 at 03:13
  • @Prefix I haven't found a solution yet. – huggie May 29 '17 at 11:45
  • On Mac, I just tried the `CMD + ALT + LEFT/RIGHT` and it works as expected across tabs and groups, it just cycles through tabs in order, jumping to a new group when expected. I tried `CMD + number` and if you have 2 groups currently you can switch between with `CMD + 1` and `CMD +2` and if you press `CMD + 3` it opens a third new split. – Davos Jun 12 '19 at 06:33
  • 1
    What is the keybinding name for making the behavior for CMD + (1,2,etc) switch to that tab rather than the group windows? – Fields Jul 06 '20 at 16:13
  • 12
    On Mac CTRL + (1, 2, etc) – ralixyle Jun 11 '21 at 19:30
  • It works for me in Manjaro. – Victor Avila Aug 16 '22 at 00:22
142

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

yestema
  • 6,932
  • 4
  • 23
  • 29
78

If you are using the VSCodeVim extension, you can use the Vim key shortcuts:

Next tab: gt

Prior tab: gT

Numbered tab: nnngt

gabra
  • 9,484
  • 4
  • 29
  • 45
30

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

Community
  • 1
  • 1
Alex Smith
  • 301
  • 3
  • 2
  • 13
    Is it possible to change it to `CMD+1, CMD+2, and CMD+3` instead of `CTRL+1, CTRL+2, CTRL+3`? – David Aug 30 '17 at 09:11
  • 2
    And also `CMD + ALT + LEFT/RIGHT` to just cycle all tabs in all groups. – Davos Jun 12 '19 at 06:35
  • 2
    @David yes, you can customize the keyboard shortcuts. The settings are available in the Preferences GUI, or just put lines like this in your `keybindings.json`: `{ "key": "cmd+1", "command": "workbench.action.openEditorAtIndex1" }, { "key": "cmd+2", "command": "workbench.action.openEditorAtIndex2" }, {"key":"cmd+3" ....` – Chris Feb 14 '22 at 23:00
25

Windows

previous

Ctrl + Shift + Tab

Next

Ctrl + Tab

Mac OS

previous

Shift+ Cmd + [

Next

Shift + Cmd + ]

Misha Akopov
  • 12,241
  • 27
  • 68
  • 82
ABlue
  • 664
  • 6
  • 20
14

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" 
    }
Piyush Patel
  • 1,212
  • 15
  • 19
  • 2
    Overriding alt+right/left prevents default, useful editor behavior to jump cursor to previous/next word. – karni Jul 02 '18 at 22:29
  • Keyboard bindings are always a better of preference, it's really not fair to call any particular choice "better". Also in this case, that same functionality is already available by default in VS Code with "Cmd+Shift+[". I still prefer the ability to insta-jump the 1st, 2nd, etc tab. – Chris Feb 14 '22 at 23:01
9

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:

  1. Navigate to: Code > Preferences > Keyboard Shortcuts
  2. Search or navigate down to the following two options:
    • View: Open Next Editor
    • View: Open Previous Editor
  3. Change both keybindings to the desired key sequence.
    • View: Open Next Editor -> (Ctrl+Tab)
    • View: Open Previous Editor -> (Shift+Ctrl+Tab)
  4. 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".

m0nsoon
  • 101
  • 1
  • 4
8

There are multiple ways through which you would can toggle the tabs.

  1. Modern browser way based on position.
{
       "key": "ctrl+tab",
       "command": "workbench.action.nextEditor"
   },
   {
       "key": "ctrl+shift+tab",
       "command": "workbench.action.previousEditor"
   }
  1. Recently sorted
{
   "key": "ctrl+shift+tab",
   "command": "workbench.action.openNextRecentlyUsedEditor"
 },
 {
   "key": "ctrl+tab",
   "command": "workbench.action.openPreviousRecentlyUsedEditor"
 }
Janus
  • 81
  • 1
  • 2
7

for linux... I use ctrl+pageUp or pageDown

jmsalcido
  • 1,057
  • 11
  • 16
7

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.

https://media.githubusercontent.com/media/microsoft/vscode-docs/vnext/release-notes/images/1_45/scroll-tabs.gif

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).

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
6

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

6

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"
    }
]
hugomosh
  • 402
  • 6
  • 15
6

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

Jthorpe
  • 9,756
  • 2
  • 49
  • 64
6

This functionality is now default in vscode using alt instead of ctrl:

enter image description here

enter image description here

Matthew
  • 668
  • 5
  • 12
5

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"
  }
Johnny Oshika
  • 54,741
  • 40
  • 181
  • 275
  • +1 Yes, this is also explained in the [official documentation](https://code.visualstudio.com/Docs/editor/editingevolved): `[ { "key": "ctrl+tab", "command": "workbench.action.quickOpenPreviousRecentlyUsedEditor", "when": "!inEditorsPicker" }, { "key": "ctrl+shift+tab", "command": "workbench.action.quickOpenLeastRecentlyUsedEditor", "when": "!inEditorsPicker" } ] ` – klopps Apr 04 '21 at 09:28
  • This is the right solution for anyone that is used to the Jetbrains suite! Thanks! – Ares9323 Jan 26 '23 at 15:59
4

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.

mdiiorio
  • 126
  • 2
  • 13
4

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 prevEditorInGroup and Keybind it to alt+<-(left errow). 5.) now you can pass around the tabs by alt+left or alt+right!

4

VSCode 2022 and 2023

  1. File → Preferences → Keyboard Shortcuts (or Ctrl + K and then Ctrl + S)

  2. Type "ctrl tab" in the search bar

  3. Replace the existing key bindings (highlighted on the picture with red colour) with any other, or right-click and select "Remove"

  4. Find "View: Open Next Editor" through the search bar, and replace "Ctrl + Page down" with "Ctrl + Tab".

  5. Do the same thing with "View: Open Previous Editor"

enter image description here

nnnmmm
  • 7,964
  • 4
  • 22
  • 41
JacobTheKnitter
  • 415
  • 5
  • 7
2

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.

Mukundhan
  • 3,284
  • 23
  • 36
1

Use Sublime Text Keymaps. So much more intuitive.

km

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
relik
  • 287
  • 5
  • 15
1

@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"
    }
Misha Akopov
  • 12,241
  • 27
  • 68
  • 82
openwonk
  • 14,023
  • 7
  • 43
  • 39
1

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.

1

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.

Jordan Nakamoto
  • 251
  • 2
  • 4