Chrome Tab Ordering?

Nathan's clever how-to below on forcing a ctrltab shortcut via devtools needs an update, since the extensions page code is now minified from Chrome 65 on. To simplify the process, I wrote a little snippet below that you can copy and paste into the console that lets you then just click a command to set its shortcut to ctrltab.

  1. Open chrome://extensions/shortcuts by pasting that into the location bar or going to the main menu > More Tools > Extensions, and then clicking the menu in the top-left to open Keyboard shortcuts.
  2. Open the devtools console by pressing cmdoptJ on macOS or ctrlshiftJ on Windows/Linux.
  3. Copy this code:

    document.body.onclick = function(e) {
        gCT = !window.gCT;
        var p = e.path, cn = p[0].textContent,
            s = p.filter(p => p.className == "shortcut-card")[0],
            n = s && s.children[0].children[1].textContent;
        n && chrome.management.getAll(es => {
            var ext = es.filter(e => e.name == n)[0], id = ext.id;
            chrome.developerPrivate.getExtensionInfo(id, i => {
                var c = i.commands.filter(c => c.description == cn)[0];
                chrome.developerPrivate.updateExtensionCommand({
                    extensionId: id,
                    commandName: c.name,
                    keybinding: "Ctrl+" + (gCT ? "" : "Shift+") + "Tab"
                });
            });
        });
    }
    
  4. Paste it into the console next to the > and then press enter.

  5. Go back to the shortcuts page and click the label of the command you want to set to ctrltab, not the Type a shortcut field. As an example, for the QuicKey tab manager extension, the label is Switch to previous tab.

That's it! ctrltab will appear as that command's shortcut as soon as you click it. If you want another command to get a ctrlshifttab shortcut, just click its label next. (The code will switch between these two shortcuts as you click.) These shortcuts will survive Chrome restarts, since it's the app itself writing to its preferences file.


If you want to use my QuicKey extension to navigate tabs, there's a somewhat simpler process outlined here that doesn't require clicking around in the keyboard shortcuts page. The snippet of JS code used there is also more self-explanatory, in case you're wary of what the blob above is doing.

If you're on Windows, that page also outlines a way of getting something much closer to Firefox's ctrltab menu, using an AutoHotkey script.


Most-Recently-Used tab ordering in Chrome has finally become an option, though it is undocumented, unsupported, hacky and complaints about the situation are ignored.

To get the desired behavior:

  1. Install the Ctrl-TAB MRU extension. This extension provides MRU tab ordering that replaces the built-in tab switching mechanism. You can bind it to any key you want, so long as the extension manager keyboard shortcut mapper can record it. It can't record Ctrl-TAB or Ctrl-Shift-TAB. Previously this meant suffering with sub-standard workarounds like binding to Ctrl-~. But now there is a way, so:
  2. To work around the lack of a non-recording way to set key combos, in the keyboard shortcut recorder set the bindings to the Ctrl+Tab MRU extension to something stupid like Ctrl-Shift-Q and Ctrl-Shift-X, to make it easy to search for. Test out these shortcuts to see how the extension looks and behaves.
  3. Close Chrome and use a text editor to open "%AppData%\local\google\Chrome\User Data\Default\Preferences" (%AppData% depends on your OS; in windows that's probably C:\Users\USERNAME\AppData) This file contains all of your settings in JSON format, all crammed onto a single line.
  4. Search for the two bindings you set earlier (Ctrl-Shift-Q and Ctrl-Shift-X) and edit them to Ctrl-Tab for next and Ctrl-Shift-Tab for previous.
  5. Start Chrome, open three tabs and test switching between them with your new shortcuts. If you don't see the behavior from step 2, go back to step 3 and try again. For unknown reasons, Chrome occasionally ignores your Preferences file and then overwrites it (see below).

Caveats:

  • Every time you close Chrome, it will clobber your Preferences file and reset your manually-created keybindings. Also every time you edit an extensions settings or open Chrome or squint at Chrome funny. You can mark the file ready-only (which might have negative side effects) or you can get used to editing your Preferences file frequently. Or never close Chrome. This is Chrome's fault for not thinking that keybinding is valid and removing it, even when it honors it.

  • The Ctrl+Tab MRU extension won't trigger in a new tab until the tab has finished loading. This is Chrome's fault.

  • The Ctrl+Tab MRU extension has a clumsy workaround for using it on tabs that don't contain pages (blank tabs, settings tabs, etc) where it quickly creates a new tab, switches tabs and closes the new tab. This is Chrome's fault.


I've found a different way to change your keybindings for an extension to CTRL+TAB and CTRL+SHIFT+TAB that works with the Ctrl-TAB MRU extension that GDom posted. It syncs to your profile and doesn't reset when Chrome Sync syncs on load like editing the preferences does. I do it by using the debugger to manipulate the keybindings page.

I made a how-to on it: How to bind an extension to Ctrl+Tab/Ctrl+Shift+Tab in Chrome and have it actually sync to your profile