" Always display the status line even if there is only one window.
set laststatus=2
+ " If there's more than one buffer return "/<nr>" (e.g. "/05") where <nr>
+ " is the highest buffer number, otherwise return nothing. Used in
+ " 'statusline' to get an overview of available buffer numbers.
+ function! StatuslineBufferCount()
+ let l:bufnr = bufnr('$')
+ if l:bufnr > 1
+ let l:result = '/'
+ if exists('*printf')
+ let l:result .= printf('%02d', l:bufnr)
+ else
+ " Older Vims don't have printf() (and no .= either). Emulate
+ " "%02d".
+ if l:bufnr < 10
+ let l:result = l:result . '0'
+ endif
+ let l:result = l:result . l:bufnr
+ endif
+ return l:result
+ else
+ return ''
+ endif
+ endfunction
+
set statusline=
" on the left
- set statusline+=%02n: " buffer number
+ set statusline+=%02n " buffer number
+ set statusline+=%{StatuslineBufferCount()} " highest buffer number
+ set statusline+=:
set statusline+=%f\ " path to current file in buffer
set statusline+=%h " [help] if buffer is help file
set statusline+=%w " [Preview] if buffer is preview buffer