May 212009

To start off my reinvigorated vim education, I looked into why I get a helpful info bar when I have :split windows, but not when I am looking at a single file. The bar is called the statusline (:help status-line), and you can change the visibility option with

set laststatus=<#>

It defaults (on my system) to 1, meaning that it only shows for split windows. To make it always show, set it to 2.

The helpdoc informs us that you can set the content of the statusline with:

set statusline=[some string]

[some string] is a printf-style string, with a host of items it can display (:help statusline). I liked the default (with the rails.vim addition of rails filetype information), but I wanted to also see the buffer number, because I’ve been playing around with buffer management. Here’s what I ended up with, in my .vimrc:

set statusline=
set statusline+=%< " cut at start
set statusline+=%2*[%n%H%M%R%W]%* " buffer number, and flags
set statusline+=%-40f " relative path
set statusline+=%= " seperate between right- and left-aligned
set statusline+=%1*%y%*%* " file type
set statusline+=%10((%l/%L)%) " line and column
set statusline+=%P " percentage of file

Which gives a statusline like:

[10] app/models/user.rb          [ruby][Rails-model-arb]    (1/276) Top

  One Response to “Vim Statusline”

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>