Status Line in Vim

If you are following the recent trends in the Vim community you have probably noted the ever growing popularity of Powerline. As the name suggests, it is a very powerful status line generation plugin, but I don’t think that’s why most people use it. I believe its popularity has a lot to do with how sexy it looks on the bottom of your screen.

To be honest, I was never that fond of that particular extension for a variety of reasons. One of my chief gripes with it is directly related to the way it looks. Powerline uses non-standard patched fonts in order to achieve that segmented look which is not something Vim supports natively. Without them the extension looses a lot if it’s sex-appeal and starts looking a bit plain. To configure it, you don’t just add entries to your .vimrc but instead you need to create a separate dot-folder where it’s settings files are kept. While this neatly separates the Powerline setup from general Vim settings it also adds maintenance headaches. I like to keep all my Vim related config files in a single directory under source control so you can imagine this is less than optimal.

Finally, I have never really felt like I would use any of it’s advanced features. Most of the power-line setups I see on screenshots and in screen-casts are very basic: mode indcation, file path, some file and cursor position info. All of that can be easily set up in just a few lines of VimL. Powerline on the other hand is a monstrous semi-framework that can let you do really frivolous and complex things. For example, it has support for hooking into your power management module by the way of python and displaying battery status in Vim. It can also pull weather notifications from the web and display them in your status line… Though why would you ever want that is beyond me.

It is really a nice an powerful plugin, but it doesn’t seem like something I would necessarily need. For years I have been pretty happy using a very simple status line with just the name of the file and some positioning info along side the excellent Obvious-Mode plugin. It covered most of my needs – my status line would be red in insert mode, gray/cyan in normal mode, depending on whether or not the file had any unsaved changes.

Lately however I decided that I could use more informative status line. I briefly flirted with the concept of using Powerline but since I’m a system nomad who drags his .vim folder wherever he goes that idea died pretty quickly. Instead I decided to create my own status line which displays the information that I care about in a Powerline-like way but without any fancy fonts.

The killer feature for me is that I wrote it. By that I mean that if something breaks or doesn’t work correctly can easily figure out why, and fix it. Power line is pretty big and has a lot of moving parts, whereas my status line is just a dozen lines of very basic VimL so if it breaks, I can easily handle it without loosing too much time.

The result looks like this:


Vim-NeatStatus Plugin

The mode indicator on the left changes color depending on the mode: green in normal, red in insert and blue in replace mode. I also had it turn purple in visual mode but it was kinda buggy (always lagged one keystroke behind) so at the moment it doesn’t do that. I still use Obvious-Mode so this functionality isn’t strictly necessary, but I included it so that it could be used as a stand-alone plugin.

The black box next to mode indicator shows you the server name (which in my case is treated as session name). This may not be useful to everyone, but since I set up my Vim to save sessions on exit I actually like to see that information somewhere.

To the left of the file path I have file type (ie. what language vim thinks this file is written in), file format (important if you jump between systems as much as me) and encoding (as in utf8 or not). The last may not seem fairly relevant to you, but sometimes it does matter: especially if you are trying to parse files in a certain way, or if you create a script that doesn’t run properly because the non-vim text editor decided to insert a BOM in it for shits and giggles.

Next I have the buffer number (which is useful when you have a lot of buffers open) and cursor positioning info with the current line highlighted in pink to stand out and be easily readable. There is also one more bit that is not visible in the picture above: whenever you edit a file, a little pink notification appears in the right corner of your status bar to let you know that the file has unsaved changes. Once again this is a duplication of Obvious-Mode functionality but it can be useful if you decide to install it as a stand-alone.

The colors work both in the graphical Vim as well as in the console (though you may need one that supports 256 colors). I tested it in in Gvim, MacVim and using Gnome-Console as well as Cygwin MinTTY on Windows.

I made the entire thing available as a plugin that can be easily installed via Pathogen like this:

cd ~/.vim/bundle
git clone git://

If you have your .vim under source control like me then do:

cd ~/.vim
git submodule add git:// bundle/vim-neatstatus
git submodule init
git submodule update

At the moment the colors are hard coded and the plugin is not very configurable as a whole, but that will likely change in the future. If something is broken or the colors look atrocious under some setups let me know and I will try fixing it.

Are you able to change the status line in your favorite text editor? If yes, what kind of information do you put there? Have you written your own status line or are you using a plugin written by someone else?

This entry was posted in programming and tagged . Bookmark the permalink.

8 Responses to Status Line in Vim

  1. Scott Hansen UNITED STATES Mozilla Firefox Linux says:

    I agree…Powerline seems way too heavy! If tmux and my own custom statusbar for my window manager didn’t exist, then I’d consider it! My vim statusline is pretty stock, with the exception of adding git status from the vim-fugitive plugin (which I admit I _want_ to use more, but I rarely think about it since I normally have several terminals open in tmux already to take care of CLI stuff like git).

    set statusline=%<%f\ %{fugitive#statusline()}\ %h%m%r%=%-14.(%l,%c%V%)\ %P


    Reply  |  Quote
  2. Ein Mozilla Firefox Windows says:

    Perfect timing. My goodness could I not agree with you more regarding powerline. I was just going through your vim configuration post yesterday. Funny enough, the Obvious-Mode plugin on says it is depreciated in favor of powerline, and powerline on in turn says it is depreciated in favor of a beta python implementation on github. You can guess which plugin I naively opted for (and I was not happy with my time spent fucking with it). This is much better for me.

    Reply  |  Quote
  3. Robert FRANCE Google Chrome Windows says:

    Thanks this is great! I was messing with powerline yesterday, and I came to the conclusion it’s probably better to just keep it native so I can eaisly move my vim config to other systems and have it look the same.

    Reply  |  Quote
  4. grainneWhale IRELAND Google Chrome Windows says:

    Lovely, this is exactly what I’ve been looking for (I could never get powerline to work nicely and consistently on multiple different OS’s so I gave up on it).

    One very minor niggle – the ‘COL’ part of the cursor position section displays single digit columns as 0-9 instead of 00-09, which causes an annoying little visual distraction as the bottom right section shifts back and forth as you move around. Is there an easy way to fix this?

    Reply  |  Quote
  5. Zach Gotsch Google Chrome Mac OS says:

    I definitely agree with you that Powerline feels really heavyweight. One of the most important things for me in a statusline is an obvious way to tell if the buffer has been modified since the last save. I use Airline, which turns purple when I have unsaved modifications.

    Reply  |  Quote
  6. yacoob IRELAND Google Chrome Mac OS says:

    Or you can just use vim-airline.

    Reply  |  Quote
  7. Avi INDIA Google Chrome Mac OS says:

    You should really check out vim-airline . It has almost all of the features of powerline, but is very small, starts up instantly and is very extensible. I’ve been using it for a couple of months now and it’s great.

    Reply  |  Quote
  8. Gayan SRI LANKA Mozilla Firefox Ubuntu Linux says:

    @ Robert:

    Why not just use Vim Airline with Vundle? Normally I just share my .vimrc file across multiple systems and Vundle do automatically take care of downloading the plugins and their contents.

    # update
    I too have wrote a detailed guide on installing and configuring Powerline and Airline:

    Reply  |  Quote

Leave a Reply

Your email address will not be published. Required fields are marked *