Thursday, December 22, 2011

condition in statusline, how ?

I want to make a condition in statusline setting.
for example: when fileformat is unix, show "unix" with black color in statusline, if fileformat is
"dos", then show in statusline with *red* color.
here is my statusline setting in my vimrc file:

<code>
" item form: %-0{minwid}.{maxwid}{item} --> minwid: min-width,
" %4 width, %-4 padding on the right instead of the left. %= switch to right side.
" %04l pad with zeros instead of spaces. like 0012.
" %.20F change the maximum width. The path will be truncated if necessary: <hapters/17.markdown.
" Require: fugitive, current-func-info,
set statusline=\%#StatusSeparator#\|\%#StatusBufferNumber#\b\:%n\%#StatusSeparator#\|
\\%#StatusReadOnly#\ \%r\ \%#StatusModFlag#\%m\ \%#StatusList#\%q
\\ %=\ %<%-15(\%#StatusNormal#\%{&ff}\%#StatusChar#\X\%#StatusNormal#\%{&fenc}%)
\\ \%#StatusChar#\X\ \%#StatusLineNumber#\%-(L:%l/%L\ C:%c%V%)\ \%#StatusPercent#\%P
"" FIXME write this function.
"function StatusLineFileFormat(ff)
"if &ff == 'unix'
"return a:ff
"elseif &ff == 'dos'
"return a:ff " show with red color in statusline.
"endif
"endfunction
</code>

I do not know vimscript language, so I do not know how to write upper StatusLineFIleFormat()
function. :P

--
>> stardiviner << =>GPG: 5D9F64D8 Twitter: @numbchild
http://stardiviner.dyndns-blog.com/author.html

No comments: