Created
April 23, 2011 23:20
-
-
Save anyakichi/939080 to your computer and use it in GitHub Desktop.
Close duplicate tabs and show hidden buffers in tabs.
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
function! ReorganizeTabs(only) | |
let tablists = [] | |
let bufs = {} | |
tabfirst | |
let tabnr = 1 | |
while type(tabpagebuflist(tabnr)) == type([]) | |
let tablist = tabpagebuflist(tabnr) | |
if a:only && len(tablist) > 1 | |
execute "normal! 999\<C-w>k" | |
only | |
endif | |
if !empty(filter(copy(tablists), 'v:val == ' . string(tablist))) | |
tabclose | |
continue | |
endif | |
call add(tablists, tablist) | |
for i in tablist | |
let bufs[i] = 1 | |
endfor | |
tabnext | |
let tabnr += 1 | |
endwhile | |
tablast | |
for n in range(1, bufnr('$')) | |
if get(bufs, n, 0) || !buflisted(n) | |
continue | |
endif | |
tab split | |
execute 'buffer ' . n | |
endfor | |
tabfirst | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment