" 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()
+ function! s:StatuslineBufferCount()
let l:bufnr = bufnr('$')
if l:bufnr > 1
let l:result = '/'
" Like %f but use relative filename if it's shorter than the absolute path
" (e.g. '../../file' vs. '~/long/path/to/file'). fnamemodify()'s ':.' is
" not enough because it doesn't create '../'s.
- function! StatuslineRelativeFilename()
+ function! s:StatuslineRelativeFilename()
" Display only filename for help files.
if &buftype == 'help'
return expand('%:t')
endfunction
" Return current syntax group in brackets or nothing if there's none.
- function! StatuslineSyntaxGroup()
+ function! s:StatuslineSyntaxGroup()
let l:group = synIDattr(synID(line('.'), col('.'), 1), 'name')
if l:group != ''
return '[' . l:group . '] '
endif
endfunction
+ " Short function names to make 'statusline' more readable.
+ function! SBC()
+ return <SID>StatuslineBufferCount()
+ endfunction
+ function! SRF()
+ return <SID>StatuslineRelativeFilename()
+ endfunction
+ function! SSG()
+ return <SID>StatuslineSyntaxGroup()
+ endfunction
+
set statusline=
" on the left
set statusline+=%02n " buffer number
- set statusline+=%{StatuslineBufferCount()} " highest buffer number
+ set statusline+=%{SBC()} " highest buffer number
set statusline+=:
if has('modify_fname') && v:version >= 700 " some functions need 7.0
- set statusline+=%{StatuslineRelativeFilename()} " path to current file
+ set statusline+=%{SRF()} " path to current file
set statusline+=\ " space after path
else
set statusline+=%f\ " path to current file in buffer