In between multiple tabs, how to use Vimperator to open a tab right after the current one

Method 1: General

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<SPACE>

command! newtabright -nargs=1 -description "Open new tab to right of current tab" :js newTabRight("<args>");

:js <<EOF
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.comEnter


Method 2: requires about.config setting browser.tabs.insertRelatedAfterCurrent

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

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