From 55d1fc84f5ccf450bcca9407baa9dec64cd70b6a Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Tue, 20 Nov 2012 22:18:13 +0100 Subject: [PATCH] vimrc: Use short function names in 'statusline'. --- vimrc | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/vimrc b/vimrc index c594169..63b4acf 100644 --- a/vimrc +++ b/vimrc @@ -303,7 +303,7 @@ if has('statusline') " If there's more than one buffer return "/" (e.g. "/05") where " 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 = '/' @@ -326,7 +326,7 @@ if has('statusline') " 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') @@ -386,7 +386,7 @@ if has('statusline') 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 . '] ' @@ -395,13 +395,24 @@ if has('statusline') endif endfunction + " Short function names to make 'statusline' more readable. + function! SBC() + return StatuslineBufferCount() + endfunction + function! SRF() + return StatuslineRelativeFilename() + endfunction + function! SSG() + return 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 -- 2.44.1