The default vim status line can work well but vim-airline inhances it in many ways. Vim-airline is a simple lightweight plugin that integrates with many other popular plugins out of the box (but they are not required). In this post you will learn how to get vim-airline setup with some basic settings and a theme.

Install vim-airline

In order to use vim-airline you need to install it. I use vim-plug to manage my plugins so installing vim-airline (and themes) is as simple as adding the following to my vimrc:

call plug#begin('~/.vim/plugged')
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
call plug#end()

Now that we have airline installed you should see a new status line when you open up vim.

Image of vim-airline status line

Basic Settings

Out of the box vim-airline is very complete. You get the basic features including of having a colored status line based on the current mode. With several other useful indicators for the file you are in (like line count, cursor position, detected filetype, and file name). However, vim-airline includes many other things that are off by default. My favorite is the buffer list across the top of your terminal. Add the following to your vimrc to enable it

let g:airline#extensions#tabline#enabled = 1 " Enable the list of buffers

With this setting added you now have a visual for all the buffers you currently have open as well as the currently active buffer. If you are currently using “tabs” in vim as “tabs” you are doing it wrong and should make the switch to using buffers as they should be used. The default filename formatter will truncate all but the filename. You can change that with this setting:

" ~/full/path-to/file-name.js
let g:airline#extensions#tabline#formatter = 'default'  " f/p/file-name.js
let g:airline#extensions#tabline#formatter = 'jsformatter' " path-to/f
let g:airline#extensions#tabline#formatter = 'unique_tail' " file-name.js
let g:airline#extensions#tabline#formatter = 'unique_tail_improved' " f/p/file-name.js

I prefer the default or unique_tail_improved but your projects may differ from mine (some JavaScript projects have lots of index.js files so the jsformatter might make more sense).

vim-airline Themes

The default theme works but it is not that pretty and it probably does not go with the theme you use. Thankfully we installed the airline-themes plugin which comes with many themes. You can set the theme using the following command inside vim to try them out

:AirlineTheme tomorrow
:AirlineTheme automic

You can also find screenshots in the airline-themes wiki. Find one that you want and set your theme in your .vimrc. I use the Base16 Tomorrow Night theme which goes really well with the tomorrow theme from vim-airline-themes.

let g:airline_theme='tomorrow'

Custom symbols

Many screenshots floating around have fancy powerline fonts included. These aren’t necessary but they do make the status line look fancy. Make sure you have the powerline fonts installed (sudo apt-get install fonts-powerline for Debian based systems). Once those are installed you need to adjust your symbols settings.

" Note: You must define the dictionary first before setting values.
" Also, it's a good idea to check whether it exists as to avoid
" accidentally overwriting its contents.

if !exists('g:airline_symbols')
  let g:airline_symbols = {}
endif

" powerline symbols
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = '☰'
let g:airline_symbols.maxlinenr = ''
let g:airline_symbols.dirty='⚡'

" If you only see boxes here it may be because your system doesn't have
" the correct fonts. Try it in vim first and if that fails see the help
" pages for vim-airline :help airline-troubleshooting

Now the status line has some extra fancy symbols for version control. (If you run into issues checkout :help airline-customization or :help airline-troubleshooting).

Integration with other plugins

Vim-airline will automatically detect functionality for other plugins. If you have Tim Popes fugitive.vim plugin installed for working with Git vim-airline will automatically add a section for your VCS status (such as the current branch name). Many other VCS plugins are supported by I use fugitive.

There are several other supported plugins and extensions that can be installed or enabled. Checkout :help airline-extensions to read more.

Conclusion

Image of vim with all vim-airline settings

Congratulations you should now have a working vim-airline status line that is custom to your needs. If you have any more questions you can find more info about the plugin using the vim help system by running :help airline. All the configurations from here are in there as well as many more. There are even instructions for how to integrate your plugin with vim-airline! Good luck and happy vimming!