Setup powerline in Vim for Linux/OS X

To use powerline in VIM, the default plugin vim-powerline may have been out-of-date. I suggest to use the modern plugin, vim-airline, which provides amazing status-bar settings and powerline styles. In additional, it has accompanied plugin vim-airline-themes to allows users to easily adjust powerline styles.

Install Airline via Vundle

1
2
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'

If you use other package manager plugins, you may go to https://vimawesome.com/plugin/vim-airline-superman for more information. VimAwesome is a very cool website that lists most popular vim plugins by their popularity.

Setup Powerline font

This is important, since powerline-style status bar uses some special characters/symbols. Go to https://github.com/powerline/fonts, where you can find patched fonts to support powerline. For example, I use Roboto Mono, so I download and install all .ttf in the font folder Roboto Mono.

To allow Vim to use these patched fonts to show symbols in powerline, we need to configure the terminal font (for Vim in terminal) or the font type for GVim.

  • Vim in Terminal:

    • iTerm2: change font to Roboto Mono for Powerline

    • URxvt: set the font by URxvt.font: xft:RobotoMono:size=11 in ~/.Xresources (remember to run xrdb .Xresources before running vim)

  • GVim or MacVim: Adding the configuration of guifont in .vimrc. For Linux, (due to strange bugs or nonuniform legacy ), use set guifont=Roboto\ Mono\ for\ Powerline\ 15. For MacOX or Windows, use set guifont=Roboto\ Mono\ for\ Powerline:h15.

More configurations on Airline or Airline themes

You may choose whatever you prefer from the following in my .vimrc:

1
2
3
4
5
6
7
8
9
10
11
12
" ---- vim-airline ----
" require powerline-symbol patched font installed
" install Roboto Mono given in .vim/fonts/
let g:airline_powerline_fonts = 1
" remove empty angle at the end
let g:airline_skip_empty_sections = 1
" set airline theme
"let g:airline_theme='deus'
" extension for tab line
let g:airline#extensions#tabline#enabled = 0
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#formatter = 'unique_tail'