Nik Kantar

Friday, January 13, 2017

My Vim Statusline

I don't use Airline or anything fancy, but my statusline still tells me everything I need to know.

I’ve been asked exactly what my Vim statusline says, since so many Vim users seem to expect everyone else to use Airline. Here’s what it looks like, for reference:

Vim statusline

And here’s the relevant .vimrc snippet:

set statusline=

set statusline+=%F                            " current file path
set statusline+=\                             " blank space
set statusline+=%y                            " filetype
set statusline+=\                             " blank space
set statusline+=%m                            " modified flag [+]
set statusline+=\                             " blank space

set statusline+=%=                            " right-align from now on

set statusline+=%{PasteForStatusline()}       " paste flag
set statusline+=\[%{mode()}\]                 " current mode
set statusline+=\                             " blank space
set statusline+=%v                            " column number
set statusline+=\:                            " colon separator
set statusline+=%l                            " row number
set statusline+=\/                            " slash separator
set statusline+=%L                            " number of rows
set statusline+=\                             " blank space
set statusline+=%{winnr()}                    " buffer number

set statusline+=%#warningmsg#                 " Syntastic error flag
set statusline+=%{SyntasticStatuslineFlag()}  " Syntastic error flag
set statusline+=%*                            " Syntastic error flag

Finally, let’s run through the interesting pieces one by one:

mode() and winnr() are Vim built-ins and SyntasticStatusFlag() is part of the plugin, but PasteForStatusLine() is this:

function! PasteForStatusline()
    let paste_status = &paste
    if paste_status == 1
        return " [paste] "
        return ""


OK, “FAQ” is a bit facetious, but I’d like to preemptively answer a few at least tangentially related questions.

What about Git status and such?

I rely on vim-gitgutter for the lines I’m interacting with, vimagit for creating commits, and the git command line interface for everything else.

What’s that color scheme?


What in the world is “Alacritty”?

Alacritty is a really fast terminal emulator I quite like.