Skip to content

Instantly share code, notes, and snippets.

@troyp
Last active February 27, 2016 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save troyp/20e4b1f744c5e799f1df to your computer and use it in GitHub Desktop.
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`
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