statusline

http://d.hatena.ne.jp/janus_wel/20091203/1259837870 の他にもいろいろ試行錯誤をして今おれの vim の 'statusline' はこんな感じになっている。

" statusline {{{2
" %3(%m%) : modified flag (bracketed, fixed)
" %< : where to truncate line
" %3n : buffer number (3 digit)
" %t : filename (only leaf)
" %y : filetype (bracketed)
" %{&fenc!=#""?&fenc:&enc} : fileencoding
" %{&ff} : fileformat
" %r : read only flag (bracketed)
" %= : spliter left between right
" %{tabpagenr()} : current tabnumber
" %{tabpagenr("$")} : tabpage count
" %v : virtual column
" %l : line number
" %L : lines count
" %{strtrans(matchstr(getline("."),".",col(".")-1))} : chars under the cursor
" 0x%04B : hexadecimal octets
" %4P : percentage through file of displayed window
let s:statusline = [
            \ '%3(%m%) %<%3n %t %y',
            \ '[%{&fenc!=#""?&fenc:&enc}:%{&ff}]',
            \ '%r',
            \ '%=',
            \ '[%{tabpagenr()}/%{tabpagenr("$")}]',
            \ '[%v:%l/%L]',
            \ '[%2(%{strtrans(matchstr(getline("."),".",col(".")-1))}%)',
            \ ' 0x%04B]',
            \ '[%4P]',
            \ ]
let &statusline = join(s:statusline, '')
unlet s:statusline

以下変遷。幅固定とちょんぎる位置の指定を併用することによって常に modified flag を表示することが出来ることに気付いたり不可視文字の可視化に strtrans() 関数が使えるのに気付いたときはちょっと感動した。