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 startset statusline+=%2*[%n%H%M%R%W]%*        " buffer number, and flagsset statusline+=%-40f                    " relative pathset statusline+=%=                        " seperate between right- and left-alignedset statusline+=%1*%y%*%*                " file typeset statusline+=%10((%l/%L)%)            " line and columnset 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

(required)

(required)

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> <pre lang="" line="" escaped="" highlight="">

© 2012 Techspeak Suffusion theme by Sayontan Sinha