5digits / dactyl

Pentadactyl and other related Gecko extensions
Other
468 stars 98 forks source link

Switching to the Most Recent Tab #132

Open daGrevis opened 8 years ago

daGrevis commented 8 years ago

Is there a way to switch to the most recent tab? When I middle-click a link or open a link in a new tab using F, Firefox opens a new tab. I'd like to switch to it. Right know I'm doing that with :tablast, but not all new tabs are opened at the end of tabbar.

krompus commented 8 years ago

CTRL-^ by default (Control - 6)

This is meant to resemble a default vim command; In vim, look up the help page: :h alternate-file

I'm not sure how to rebind this, but it should be possible.

timacs commented 8 years ago

Yeah, very useful command! I rebound it to <C-Space> with the following command: map -b <C-Space> <C-^>

vyp commented 8 years ago

@krompus

I'm not sure how to rebind this

To bind to backslash, I did:

nmap -builtin \\ <C-^>

Not sure if that's the most correct way though.

However, I don't think this is what @daGrevis wants. I think @daGrevis wants to open a background tab, and have a command to switch to that 'most recently opened' tab. Note that CTRL-^ does not do that.

daGrevis commented 8 years ago

@vyp, you are right. This is not exactly what I was looking for.

(by the way, I was using C-^ already and it was mapped to <Space><Space>)

Image scenario where you are on reddit looking at top posts. You'd like to open something in a new tab (F) and switch to that tab (?). C-^ won't work because it goes to the last tab you were before. As I mentioned earlier, right now I'm using :lasttab, but that doesn't work all the time.

krompus commented 8 years ago

Ah yes, it seems I misunderstood (skimmed the paragraph). Sorry about that.

I'm not sure if there's a way to achieve what you're looking for, but I've just set firefox to focus new tabs when they are opened, and open new tabs next to the current tab, using Tab Mix Plus. I'm not sure if it's possible to set tabs to open next to the current one natively, but this extension is very lightweight, with lots of useful options, and it's very flexible -- you could set it to only do the above if you wanted to.

With this, you could just use the left/right tab focus to switch between the current one and the newly opened one, without focusing the newly opened background tab, or press C-^/<Space><Space if you do focus the newly opened tab.

I much prefer the "open new tab next to current" functionality, as it keeps new tabs grouped with their "parent". Of course, you can still open tabs in the "last" position, by pressing C-9 to focus the last tab, and then opening a new one with whichever command you wish, or by moving the newly created tab to the last position (:tabmove 100, for example would move it to the last position, as long as you have fewer than 100 tabs, and you can bind this to a keyboard shortcut).

I highly recommend opening tabs next to the current one. I've gotten used to it, and it's pretty intuitive. I've combined this with :pintab when I'd rather they stay visible and in an assigned position on the left.

daGrevis commented 8 years ago

Thanks for the detailed response, @krompus! Tab Mix Plus is a wonderful find.

Here's what I did. After installing the extension, I configured it like this:

Events -> Open New Tab next to current one [x]
Events -> Open New Tab next to current one -> Change opening order [ ]

Then I can use :tabnext to go to last tab. It's as simple as that.

When I want the new tab at the end of tabbar, I can just ran :tabmove 9999. This workflow is really great for my needs — I'm not a big fan of tab auto-focus.

Unfortunately I can't close the issue just yet. There must be a way to switch to the most recent tab, as the title describes. I had this idea that maybe it could be possible with JavaScript. I will take a look when I'll get a moment.

bickxsler commented 8 years ago

I've been using Tab Mix Plus's

Events -> Tab Features -> Ctrl-Tab navigates in the most recently used order [x]
Events -> Tab Features -> Ctrl-Tab displays a tab list popup menu [ ]

But I got tired of the popup menu, and recently I've switched to using

:autocmd LocationChange .* :tabm 0

Now :buffer displays tabs in most recently used order. It's a big change, but I'm liking it.