My tabs:
[1] [2] [3] [4] [5] [6] [7] [8] [9]
Scenario
I am working on the 5th tab on Firefox and looking for a way to open a tab between 5th and 6th and not after 9th which would be done by t or o
I do lots of research and while its going I tend to keep multiple (numinous) tabs open and sometimes I tend to keep the related ones close to each-other temporarily. In-case you were wondering why.
Answer
The following code defines a command to open an URL in a tab next to the current tab. You can place it in your .vimperatorrc
file or save it as a separate file and source it in .vimperatorrc
.
" Defines commands to open new tab to right of current tab
" Example keybinding: xt
nmap xt :newtabright
command! newtabright -nargs=1 -description "Open new tab to right of current tab" :js newTabRight("");
:js < function newTabRight(args) {
var origOrd = gBrowser.selectedTab._tPos;
var numTabs = tabs.count;
liberator.open(args, liberator.NEW_TAB)
var newTab = tabs.getTab();
tabs.move(newTab, origOrd+1);
}
EOF
I've uploaded this code as a gist, so you can download it and save it in your .vimperator
directory if you like. Then you can source it from your rc file with
:source ~/.vimperator/newtabright.vimperator
There's also a Pentadactyl version.
To open an URL in a tab to the right, just enter the following at the Vimperator command line:
newtabright www.example.com
...or, using the example keybinding, type:
xtwww.example.com
Enter
Assuming you have the about.config
setting browser.tabs.insertRelatedAfterCurrent
set to true
, you can use a simpler method (which can even - conditionally - be used without Vimperator/Pentadactyl).
Create a new bookmarklet. Name it whatever (eg. "new tab to right"), and in the location
field, enter the following:
javascript:window.open('%s');void(0);
In the keyword
field, enter a convenient keyword, eg. r
.
This is a combination or a bookmarklet and a "search" bookmark (although we're not using it to search). You can use it either from FF's location bar, or from Vimperator's open prompt. Simply type the keyword followed by the URL. So using Vimperator's keybindings, to open example.com, we'd just type:
oSpacerSpaceexample.com
Enter
With the Firefox location bar (vanilla FF)...
We can use the bookmarklet with the FF location bar as well. Using the standard FF key binding, we'd open example.com
by typing:
Ctrl-LrSpaceexample.com
Enter
...which is actually marginally quicker than the Vimperator command line.
However, using this method from the location bar won't work if you have FF's popup-blocker active (menu ▷ Preferences ▷ Content ▷ Pop-ups). This is because javascript scheme URLs entered at the location bar (or from a bookmarklet) are treated the same as javascript executed by a web page, whereas Vimperator's command line :javascript
command executes the code with it's extension privileges.
Comments
Post a Comment