Last active
November 11, 2015 14:27
-
-
Save troyp/b4b4b75a0ef59a986e94 to your computer and use it in GitHub Desktop.
Vimperator ex file defining commands to go back/forward in a duplicated tab (like middle-clicking the navigation buttons)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Vimperator ex file: add to .vimperatorrc or source with :source command | |
" Defines commands to go back/forward in a duplicated tab (equivalent to middle-clicking the navigation buttons) | |
" Example keybindings: gh and gl (replacing the builtin gh binding): | |
nnoremap gh :backt<CR> | |
nnoremap gl :forwardt<CR> | |
command! backt -description "Duplicate tab and go back in the browser history" :js backt(); | |
:js <<EOF | |
backt = function() { | |
var currT = gBrowser.selectedTab; | |
var dupT = gBrowser.duplicateTab(currT); | |
var dupTB = gBrowser.getBrowserForTab(dupT); | |
var backtListener = function () { | |
gBrowser.goBack(); | |
dupTB.removeEventListener("DOMContentLoaded", backtListener); | |
}; | |
dupTB.addEventListener("DOMContentLoaded", backtListener); | |
gBrowser.selectedTab = dupT; | |
} | |
EOF | |
command! forwardt -description "Duplicate tab and go forward in the browser history" :js forwardt(); | |
:js <<EOF | |
forwardt = function() { | |
var currT = gBrowser.selectedTab; | |
var dupT = gBrowser.duplicateTab(currT); | |
var dupTB = gBrowser.getBrowserForTab(dupT); | |
var forwardtListener = function () { | |
gBrowser.goForward(); | |
dupTB.removeEventListener("DOMContentLoaded", forwardtListener); | |
}; | |
dupTB.addEventListener("DOMContentLoaded", forwardtListener); | |
gBrowser.selectedTab = dupT; | |
} | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment