Title: Lightweight and sexy status bar in vim
Date: 2018-01-07 14:30

I'm a big fan of [vim](https://vim.org), but always thought that the vanilla
[statusline](http://vimdoc.sourceforge.net/htmldoc/options.html#'statusline')
is both ugly and useless. During the years, I've been a user of
[vim-powerline](https://github.com/Lokaltog/vim-powerline),
[vim-airline](https://github.com/vim-airline/vim-airline) and finally
[vim-lightline](https://github.com/itchyny/lightline.vim). Yesterday night, I
was both too drunk and tired to do anything useful, so I was wondering if I
could get the *same* sexy statusbar without using any plugin, and it turned out
that it's pretty easy, once you know that:

- you have to escape spaces with `\`
- everything between `%{…}` will be evaluated
- you can set colours with `%#your_colour_name#`
- everything you need to know is in `:help statusline`

I'm a bit dissatisfied by my *hack* to get the current mode in a nice way,
but I didn't manage to come up with something better. But since my vim is
already notably faster when I'm scrolling, I don't care that much.

```vim
set statusline=
set statusline+=%#DiffAdd#%{(mode()=='n')?'\ \ NORMAL\ ':''}
set statusline+=%#DiffChange#%{(mode()=='i')?'\ \ INSERT\ ':''}
set statusline+=%#DiffDelete#%{(mode()=='r')?'\ \ RPLACE\ ':''}
set statusline+=%#Cursor#%{(mode()=='v')?'\ \ VISUAL\ ':''}
set statusline+=\ %n\           " buffer number
set statusline+=%#Visual#       " colour
set statusline+=%{&paste?'\ PASTE\ ':''}
set statusline+=%{&spell?'\ SPELL\ ':''}
set statusline+=%#CursorIM#     " colour
set statusline+=%R						  " readonly flag
set statusline+=%M 						  " modified [+] flag
set statusline+=%#Cursor#				" colour
set statusline+=%#CursorLine#	  " colour
set statusline+=\ %t\ 					" short file name
set statusline+=%=							" right align
set statusline+=%#CursorLine#   " colour
set statusline+=\ %Y\ 					" file type
set statusline+=%#CursorIM#     " colour
set statusline+=\ %3l:%-2c\ 		" line + column
set statusline+=%#Cursor#       " colour
set statusline+=\ %3p%%\ 				" percentage
```

The only fancy features that it comes with are dynamic colouring of the current
mode and indication of the *paste* and *spellcheck* status.

My old bar:

![old status bar]({static}/images/vim_statusbar_old.png)

My new bar:

![new status bar]({static}/images/vim_statusbar_new.png)

The differences are intended.

You can find the rest of my vimrc [here](https://dustri.org/pub/vimrc).
