Skip to content

Instantly share code, notes, and snippets.

@unclechu
Created October 20, 2016 09:28
Show Gist options
  • Save unclechu/c4a19b9b36997989d2ea234a6d2ffeff to your computer and use it in GitHub Desktop.
Save unclechu/c4a19b9b36997989d2ea234a6d2ffeff to your computer and use it in GitHub Desktop.
Vim: Go to previous tab after current tab closed
function! s:PreviousTab_StoreState()
let s:tab_current = tabpagenr()
let s:tab_last = tabpagenr('$')
endfunction
function! s:PreviousTab_TabClosed()
if s:tab_current > 1 && s:tab_current < s:tab_last
exec 'tabp'
endif
endfunction
autocmd TabEnter,TabLeave * call s:PreviousTab_StoreState()
autocmd TabClosed * call s:PreviousTab_TabClosed()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment