Skip to content

Instantly share code, notes, and snippets.

@troyp
Last active April 29, 2017 09:00
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/6a5669785a25f626866bd1398ff422a6 to your computer and use it in GitHub Desktop.
Save troyp/6a5669785a25f626866bd1398ff422a6 to your computer and use it in GitHub Desktop.
Pentadactyl code to add `:closealltoright` and `:closealltoleft` commands (and corresponding keybindings). Add to `~/.pentadactylrc`. Vimperator versions in https://gist.github.com/troyp/20e4b1f744c5e799f1df
command! closetabstoleft
\ -description "Close all tabs to the left of the current tab"
\ -js
\ var firstTab = tabs.getTab(0);
\ var numToClose = tabs.getTab().dactylOrdinal - 1;
\ tabs.remove(firstTab, numToClose);
command! closetabstoright
\ -description "Close all tabs to the right of the current tab"
\ -js
\ tabIndex = tabs.getTab().dactylOrdinal - 1;
\ var nextTabIndex = tabIndex + 1;
\ var firstTab = tabs.getTab(nextTabIndex);
\ var N = tabs.allTabs.length;
\ var numToClose = N - nextTabIndex;
\ tabs.remove(firstTab, numToClose);
map v< -ex closetabstoleft
map v> -ex closetabstoright
" close tabs to right (inclusive) "
map <C-k> v>d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment