""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Buftabs (C) 2006 Ico Doornekamp " modified by me, adding in support for display in the ruler let g:buftabs_only_basename = 1 let g:buftabs_in_ruler = 1 function! Buftabs_show() let l:i = 1 let l:list = '' let l:start = 0 let l:end = 0 if ! exists("s:from") let s:from = 0 endif " Walk the list of buffers while(l:i <= bufnr('$')) " Only show buffers in the list, and omit help screens if buflisted(l:i) && getbufvar(l:i, "&modifiable") " Append the current buffer number and name to the list. If the buffer " is the active buffer, it is enclosed in square brackets. If it is " modified, it is appended with an exclaimation mark if bufwinnr(l:i) != -1 let l:list = l:list . '[' let l:start = strlen(l:list) else let l:list = l:list . ' ' endif " prepend the buffer # "let l:list = l:list . l:i . "-" if exists("g:buftabs_only_basename") let l:list = l:list . fnamemodify(bufname(l:i), ":t") else let l:list = l:list . bufname(l:i) endif if getbufvar(l:i, "&modified") == 1 let l:list = l:list . "!" endif if bufwinnr(l:i) != -1 let l:list = l:list . ']' let l:end = strlen(l:list) else let l:list = l:list . ' ' endif end let l:i = l:i + 1 endwhile " If the resulting list is too long to fit on the screen, chop " out the appropriate part let l:width = winwidth(0) - 12 if(l:start < s:from) let s:from = l:start - 1 endif if l:end > s:from + l:width let s:from = l:end - l:width endif let l:list = strpart(l:list, s:from, l:width) " Show the list someplace like the ruler, statusline, or in command output let g:buftabs_list = l:list if exists("g:buftabs_in_statusline") set statusline=%<%{g:buftabs_list}%=0x%B\ \ %l,%c elseif exists("g:buftabs_in_ruler") set rulerformat=%75(%<%{g:buftabs_list}%=0x%B\ \ %l,%c\ %) else redraw echon g:buftabs_list end endfunction " Hook to events if has("autocmd") autocmd VimEnter * call Buftabs_show() autocmd BufNew * call Buftabs_show() autocmd BufEnter * call Buftabs_show() "autocmd BufEnter * lcd %:p:h if v:version > 700 autocmd InsertLeave * call Buftabs_show() endif autocmd BufWritePost * call Buftabs_show() endif