Skip to content

Instantly share code, notes, and snippets.

@koturn
Last active February 11, 2018 06:08
Show Gist options
  • Select an option

  • Save koturn/c293e768563d92025bf1f0ae76c511cc to your computer and use it in GitHub Desktop.

Select an option

Save koturn/c293e768563d92025bf1f0ae76c511cc to your computer and use it in GitHub Desktop.
全タブのバッファ情報等を表示
function! s:create_winid2bufnr_dict() abort " {{{
let winid2bufnr_dict = {}
for bnr in filter(range(1, bufnr('$')), 'v:val')
for wid in win_findbuf(bnr)
let winid2bufnr_dict[wid] = bnr
endfor
endfor
return winid2bufnr_dict
endfunction " }}}
function! s:show_tab_info() abort " {{{
echo "====== Tab Page Info ======"
let current_tnr = tabpagenr()
let winid2bufnr_dict = s:create_winid2bufnr_dict()
for tnr in range(1, tabpagenr('$'))
let current_winnr = tabpagewinnr(tnr)
echo (tnr == current_tnr ? '>' : ' ') 'Tab:' tnr
echo ' --- Buffer List ---'
echo ' Buffer number | Window Number | Window ID | Buffer Name'
for nrid_pair in map(range(1, tabpagewinnr(tnr, '$')), '{"wnr": v:val, "wid": win_getid(v:val, tnr)}')
echo ' ' (nrid_pair.wnr == current_winnr ? '*' : ' ') printf('%11d | %13d | %9d | %s', winid2bufnr_dict[nrid_pair.wid], nrid_pair.wnr, nrid_pair.wid, bufname(winid2bufnr_dict[nrid_pair.wid]))
endfor
endfor
endfunction " }}}
command! -bar TabInfo call s:show_tab_info()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment