Chrome Tab Ordering?

12

6

If I'm on the first tab, and I hit Ctrl+T, I want it to open next to (to the right of) the current tab. Is there an extension for this?

I think I want to change the closed tab ordering too... but I can never remember how I like it until I play with it. I think move to the left tab is what I like.

TabMixPlus gives me these options in FF, is there a similar extension available yet? Or some hidden options in Chrome?

mpen

Posted 2010-02-04T22:10:51.670

Reputation: 9 109

Answers

2

This is not (yet) a configurable option, and it would not be possible to make an extension for this at this time. Chrome extensions (unlike Firefox ones) cannot alter the behavior of the actual browser, so this sort of thing won't be possible until (if) Google changes the way their extension system works. You'll have to use @Michelle's workaround until then.


Edit: It looks like there is now an extension that does this: Tab to the next. Also, TabsPlus selects the last-used tab after you close the current one, if that's what you're interested in.

Sasha Chedygov

Posted 2010-02-04T22:10:51.670

Reputation: 6 616

11

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.

GDorn

Posted 2010-02-04T22:10:51.670

Reputation: 211

11

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.

jdunning

Posted 2010-02-04T22:10:51.670

Reputation: 261

This is smart. I combined this solution with Quick-tabs as it enables moving backward AND forward between last used tabs

– Sharcoux – 2018-09-19T09:27:14.763

@Sharcoux, QuicKey also lets you move in both directions. It's just that it doesn't currently let you move from the current tab to the oldest used tab, to make it easy to get back to it without overshooting after you had gone back in the stack. I suppose if ctrl-shift-tab is the first press, I could let it start navigating in the forward direction. – jdunning – 2018-09-19T18:33:14.643

Amazing! Spent hours on fighting with this, preference file was keeping on overriding... Now it all works, I can toggle my least tabs! thanks! – bitec – 2019-03-08T18:35:52.807

This is great.

I can't still get over it that they haven't just put in an option to use ctr-tab like any other app with sub-windows since 1993. – Lassi Kinnunen – 2019-07-10T03:59:30.847

9

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

Nathan Ladwig

Posted 2010-02-04T22:10:51.670

Reputation: 111

You are a freaking genius! – Cristiano Fontes – 2017-11-12T11:25:05.283

1

This is excellent. I noticed that the new Material UI version of the Extensions page has minified code now, so the steps are slightly different. But it inspired me to create a little snippet of JS you can run in devtools to set a ctrl-tab shortcut just by clicking the command, without having to set breakpoints and intercept the call. My answer is below: https://superuser.com/a/1326712/736443

– jdunning – 2018-06-09T00:15:54.797

3

If you right click on a tab, and select "New tab", the new tab will open immediately to the right of the tab you clicked.

Give it a try. There's more options there you might find useful.

Michelle

Posted 2010-02-04T22:10:51.670

Reputation: 533

1Well, the whole point of this in the first place is convenience and speed. Having to right click kind of negates that. But good to know. – mpen – 2010-02-04T23:49:57.637

1

FYI, I stumbled on the default Chrome Keyboard shortcut to switch between recent tabs, it is: Ctrl+1. For me this is easier than going though changing code in the debugger to get permanent ctrl+tab setting using the Ctrl-TAB MRU extension.

Edit: There is a Chrome extension that does this now in an alt-tab menu like fasion, called Recent Tabs. I still never remember ctrl+1!

aethos

Posted 2010-02-04T22:10:51.670

Reputation: 19

ctrl+1 takes you to the 1st tab, ctrl+2 to the 2nd etc.. so not really switching back & forth – sam – 2019-03-14T11:04:33.397