I installed the Airline plugin in order to have a custom status bar, as seen in the figure below:

Enter image description here

However, my status bar is presenting the symbols <, >> and <. How do I fix this problem?

Enter image description here

Enter image description here

Enter image description here

  • 2
    Try the plugin's readme/documentation/wiki/issue tracker instead of a generic site. – romainl May 22 '15 at 7:55
  • 8
    @romainl Why we can't use this site for questions about vim plugins? I think this site should be a hub for all questions regarding vi and vim-stuff. – Alexander Myshov May 22 '15 at 8:33
  • 1
    Well, your question is not about vi, Vim or any of their clones and your chances of finding a useful answer are way higher at the places above than here. Also, the plugin's author has an issue tracker set up just for you, use it. – romainl May 22 '15 at 8:38
  • @romainl this is not my question. Actually I gave answer on this question below. But anyway this stie will be a lot more useful if questions about plugins and vim-stuff will be accepted here. – Alexander Myshov May 22 '15 at 8:42
  • Use everythingfonts.com/otf-to-ttf to convert the fonts to ttf, Example: Older XShell Versions doesn't support otf. – Bhathiya Perera May 25 '15 at 14:57
up vote 41 down vote accepted

Actually I don't understand why your question is voted down. Honestly at first I too didn't understand what needs to be done to get this nice looking toolbar. Yes I know about the README and other stuff, but I think there should be a getting started or minimum settings section in the help file.

Anyway here are the settings.

Installing the appropriate fonts

You need to install fonts into your system with symbols like branching, big triangles etc. They are not standard symbols so you need to install a patched font. You can find a lot of patched fonts here: https://github.com/powerline/fonts.

.vimrc settings

From :help airline-customization, place this code into your .vimrc file:

" air-line
let g:airline_powerline_fonts = 1

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

" unicode symbols
let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
let g:airline_symbols.linenr = '␊'
let g:airline_symbols.linenr = '␤'
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.whitespace = 'Ξ'

" airline 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 = ''

The unicode symbols section is unnecessary here if you already have a patched font but it gives you a nice fallback if you try to use other font which doesn't have the appropriate symbols.

Font settings

If you use Vim in terminal you should switch to the appropriate font in profile preferences of your terminal.

If you use gui version of Vim (MacVim, GVim) you need to set the font in .vimrc, for example: set guifont=DejaVu\ Sans:s12. You can find more information here :help guifont.

  • Hello, Alexander. I followed his instructions, but still can not get the expected result: at first installed the fonts from the site of the powerline. Then I made the settings in the .vimrc file. My .vimrc file has been shared in gist.github.com/geisonsn/641f13543b8b41fe2c12. I'm using Vundle manager plugin. – Geison Santos May 22 '15 at 15:58
  • Did you install that font in your editor? If you use vim in terminal you should install that font in the terminal, or if you use gui-version of vim (MacVim, GVim) you need to set font in the .vimrc-file, for example: set guifont=DejaVu\ Sans:s12. More information you can find here :help guifont. – Alexander Myshov May 22 '15 at 17:05
  • 2
    @AlexanderMyshov you have repeated configuration lines, where only the second in every two is required. – Vitor May 23 '15 at 2:06
  • 1
    Just created an account here at vi.stackexchange to thank you and upvote this wonderful answer of yours. Thank for relieving me thousand searches. – 0decimal0 Aug 30 '15 at 19:54
  • 1
    I think there should be a getting started or minimum settings section... I don't know if it will get deleted or not, but I've added a Dummies Guide to the vim-airline wiki based on my answer. – icc97 Jun 18 at 11:42

From the README:

Integrating with powerline fonts

For the nice looking powerline symbols to appear, you will need to install a patched font. Instructions can be found in the official powerline documentation. Prepatched fonts can be found in the powerline-fonts repository.

Finally, you can add the convenience variable let g:airline_powerline_fonts = 1 to your vimrc which will automatically populate the g:airline_symbols dictionary with the powerline symbols.

  • I found that let g:airline_powerline_fonts = 1 wasn't enough. For some reason this still didn't automatically populate the g:airline_symbols, so I had to manually populate the dictionary as per Alexander Myshov's answer. – icc97 Jun 17 at 16:35

I had the same issue after reinstalling Vim: my old patched fonts were not compatible with the new airline symbols.

The old symbols are also mentioned in the help (:help airline-customization):

" old vim-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 = '⭡'

After I put these lines in my vimrc everything went fine.

  • upvoted! currently the best for me, just the these symbols are bit higher – ryenus Jun 29 '17 at 1:16
  • 1
    You need to define the dictionary first: let g:airline_symbols = {} – PerseP Mar 5 at 13:36

This took hours to figure out, so here's more of a dummies guide for Fedora/Ubuntu, with a special section for Windows.

The first is figuring out what the hell are those strange but nice angle brackets that appear in the vim-airline status bar. The background is that airline is a pure vim version of powerline (which was python), and powerline uses UTF-8 characters to insert those angle brackets. So vim-airline just uses the same UTF-8 characters.

Then even if you do manage to get one installed they look uglier than you'd hope because the fonts don't fully work.

Configuring Vim

This is opposite to the official instructions but I had this bit wrong at the end which made me question all the font installations. So I suggest you get this configured first and then if you get the fonts working it should magically appear.

The final trick was forcing vim-airline to use the fonts it needs. In the official documentation it should just be adding let g:airline_powerline_fonts = 1 in your .vimrc. However I did this and no luck. There's more information in :help airline-customization and that gives you some simple config settings that you need, just in case. This was the final magic sauce that I needed. I don't know why this wasn't automatically created. Copy and paste the settings mentioned in Alexander Myshov's accepted answer here.

Kitchen sinking it on Fedora and Ubuntu

This is probably an overkill solution, but first you need to get it consistently working before you can simplify it.

  1. Install the general powerline font sudo dnf install powerline-fonts (or sudo apt install fonts-powerline) - this should mean that you can use any font you already have installed. If you don't have an easy way of installing like dnf/apt then there's instructions for manually doing it e.g. https://www.tecmint.com/powerline-adds-powerful-statuslines-and-prompts-to-vim-and-bash/, also the official documentation has instructions (https://powerline.readthedocs.io/en/latest/installation/linux.html#fonts-installation).

    Now close your terminal re-open and check that the Powerline symbols font is available if you edit the terminal preferences and set a custom font. You don't want to use the font directly, just check that it's available. Now try opening Vim and see if you have nice symbols.

  2. If the general powerline font didn't work or if you're trying to improve things you can try installing individual 'patched' fonts, this took a while to figure out, but you can literally just go to the folder you want in https://github.com/powerline/fonts/ and download it, the font that I've liked the most from my tests is the Source Code Pro patched font. Then just open the downloaded font file and click on 'Install'.

    If you'd rather the command line, you can install all patched fonts:

     $ git clone https://github.com/powerline/fonts.git --depth=1
     $ fonts/install.sh
     $ rm -rf fonts
    

    This will install all the patched mono fonts, but then this gives you a chance to explore the possible fonts. The font list it installs is a pretty awesome list of the available source code fonts. It also means you don't have to faff around installing each of the individual fonts that get included.

  3. Check that the font can be specified in the terminal preferences, re-open your terminal session if you're missing fonts, so note there could be two options here:
    1. The general powerline font is working in which case you can just use the base font e.g. DejaVu Sans Mono
    2. If you can't get that working the patched font that you downloaded above should be correct e.g. the equivalent for DejaVu is 'DejaVu Sans Mono for Powerline'.

Handling the delicate flower of Windows

The Powerline Fonts doesn't work with Windows so your only choice is to use a patched font. Also bash script to install all the fonts doesn't work. This means that on Windows you manually have to go into each of the fonts directories and download all the fonts yourself and install them by opening each one in turn.

I downloaded all of the Source Code Pro patched fonts and installed them. Even though you install them as individual fonts they get added to Windows as a single font 'Source Code Pro for Powerline' with a separate attribute to specify the weight.

Then add this to your .vimrc:

set guifont=Source\ Code\ Pro\ for\ Powerline:h15:cANSI

If you want to use the 'Light' font use this.

set guifont=Source_Code_Pro_Light:h15:cANSI

It doesn't make much sense as it doesn't need to include the 'for Powerline', but that's how it works (I figured it out by setting the font in GVim and then using set guifont? to check what GVim used). Also I spotted that when you use GVim to switch the font, the font rendering isn't very good. I initially discounted the Light font because when I switched using the GVim menu it rendered badly, but if you put the below into your .vimrc and restart GVim it should look lovely.

Also a nice thing is that you can set your DOS/Powershell prompt to the same font.

Tweaking

Once I actually got it working for the first time, it was really disappointing as the icons didn't fully match up. But as per the FAQ we need to do some tweaking. I started off with Inconsolata as this gives me a consistent font across Windows and Linux. You can install the general font easily on Ubuntu with apt install fonts-inconsolata This is what I got:

enter image description here

The arrows are too large and are shifted up in an ugly manner.

Then I tried all the other default Ubuntu fonts.

Ubuntu mono:

enter image description here

DejaVu Sans Mono:

enter image description here

This has the vertical position correct but the right hand side arrows have a space after them.

Why you use the patched fonts

Using the default fonts relies on the Powerline font to automatically patch existing fonts. However you can improve the look of the airline symbols by using the patched fonts. These are the equivalents using the patched fonts.

I display these all at font size 16 as I like to use a larger font, plus it shows up minor issues.

Inconsolata for Powerline:

enter image description here

This still has issues, but they are almost all solved by the dz variation.

Inconsolata-dz for Powerline dz:

enter image description here

This has a hairline fracture on the right hand side arrows, but is otherwise perfect.

Ubuntu Mono derivative Powerline Regular:

enter image description here

This still has annoying issues.

DejaVu Sans Mono for Powerline Book:

enter image description here

This has a hairline fracture on the right hand side arrows, but is otherwise perfect. I actually prefer it to the Inconsolata-dz as the LN icon is more readable.

On top of these regulars, I tried almost all the available fonts and my other favourite was Source Code Pro.

Source Code Pro for Powerline Medium

enter image description here

This does have issues at size 16 where the arrows are too big, but at size 14 it's almost unnoticeable. The branch and LN icons do overflow to the bottom, but somehow this doesn't annoy me.

Source Code Pro for Powerline Light

enter image description here

This almost completely solves the issues of the medium font's arrow sizes and makes it about perfect, although there's still the icon overflow.

Source Code Pro

When I was investigating the options for fonts there's a couple of things you notice, some font patches have the absolute minimum in details, if you compare this to the Source Code Pro list it's quite significant. Source Code Pro is a very detailed and complete font that has been considered to work in a large range of scenarios. This kind of completeness matters for edge cases.

Used as a patched font it almost perfectly displays the vim-airline bar. The benefit of so many alternatives is the use of the light font which has an even better display of the vim-airline bar.

Source Code Pro is also under continued open development on Adobe's Github repository.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.