vim-airline font issue


During my furious ride on improvements of my terminal 👨🏻‍💻, I have discovered project vim-airline which provides pretty cool status bar for vim.

Very quickly I incorporated this one into my ubuntu-deploy-scripts and I was happy.

You can see pretty nice status bar in the screenshot above. Then, after some period of time I noticed, that on my newly started Linux machines the status bar in vim is somehow corrupted.

It was just yesterday, when I decided, that this needs to be fixed no matter what.

After several Google queries and testing different combination of fonts in my iTerm2 configuration (because all of those posts suggested that it is an issue related to the font, which is not able to display that characters properly), I started to experiment in different area. I was 100% sure, that it is not the font related issue, because otherwise my terminal was able to display all the special symbols. As you can see on the picture below.

Then I started from scratch, I deployed a new machine in Scaleway and moved forward step-by-step.

  1. First I just added vim-airline event without themes:
    call plug#begin('~/.vim/plugged')
    Plug 'vim-airline/vim-airline'
    call plug#end()
  2. Then I added the Solarized theme:
    set background=dark
    colorscheme solarized
  3. As everything looked ok, I moved to the final configuration of my vim:
syntax enable
set background=dark
colorscheme solarized

" jump to the last position when reopening a file
if has("autocmd")
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif

" load indentation rules and plugins according to the detected filetype.
if has("autocmd")
  filetype plugin indent on

" Turn on line numbering. Turn it off with "set nonu"
set nu

" Case insensitive search
set ic

" Higlhight search
set hls

set autoindent   "Always set auto-indenting on"
set expandtab    "Insert spaces instead of tabs in insert mode. Use spaces for indents"
set tabstop=4    "Number of spaces that a <Tab> in the file counts for"
set shiftwidth=4 "Number of spaces to use for each step of (auto)indent"
set softtabstop=4

set incsearch        "postupne vyhledavani zapnuto
set ruler
set showcmd          "ukazuj, jake zadavam prikazy
set nowrap           "nezalamuj radky

set showmatch       " zapisete-li pravou závorku, ukáze vám k ní
set wildmenu        " doplnovanie ostavajucej casti mena v prikazovom rezime
"set mouse=a          "s mysi jde vse lepe :-)

if has("syntax")
  syntax on
  filetype on
  au BufNewFile,BufRead iptables.rules set filetype=iptables

let g:vim_markdown_folding_disabled = 1

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

let g:airline_powerline_fonts = 1

At this stage vim-airline still looked ok, no font issues. Now I was 100% sure, that it is something related to the terminal variables. I started to compare different ones such as:


All were looking ok. Then I booted another machine and applied my deploy scripts, which switched my SHELL to zsh. Now I started to compare the variables…

The only one, which was different in zsh compared to the original bash one, was $LC_CTYPE. In zsh the value was LC_CTYPE=UTF-8, but in bash it was LC_CTYPE=C.UTF-8. After changing this variable the vim status bar was back 🎉🍾.

It took me few hours to resolve it, so I hope this article will help somebody…and that’s it folks…