Last active
February 27, 2016 14:59
-
-
Save troyp/20e4b1f744c5e799f1df to your computer and use it in GitHub Desktop.
Vimperator code to add `closealltoright` and `closealltoleft` commands (and corresponding keybindings). Add to `~/.vimperatorrc`
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
js <<EOF | |
closeAllToRight = function () { | |
var current = tabs.getTab(); | |
var currentIx = tabs.index(current); | |
var nexttab = current.nextElementSibling; | |
var N = tabs.count; | |
var numToClose = N - (currentIx + 1); | |
tabs.remove(nexttab, numToClose); | |
} | |
closeAllToLeft = function () { | |
var current = tabs.getTab(); | |
var currentIx = tabs.index(current); | |
var firsttab = tabs.getTab(0); | |
var N = tabs.count; | |
var numToClose = currentIx; | |
tabs.remove(firsttab, numToClose); | |
} | |
EOF | |
" close tabs to left | |
map x< :js closeAllToLeft()<CR> | |
" close tabs to right | |
map x> :js closeAllToRight()<CR> | |
command! closealltoright :js closeAllToRight() | |
command! closealltoleft :js closeAllToLeft() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment