Configuring Powerline fonts in vim on Mac 10.8

2019-05-14 19:48发布

问题:

I am trying to get the custom fonts from powerline-fonts to work with powerline. I am running vim 7.4, compiled with Macports, on Mac OS 10.8.

I'm using vundle to install powerline (and other tools not shown here):

set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}

I've downloaded the powerline-fonts repo, and successfully installed the fonts into Font Book. I then added the following to vimrc:

set encoding=utf8
set termencoding=utf8
set guifont=Droid\ Sans\ Mono\ for\ Powerline:h14
let g:Powerline_symbols='unicode'
set t_Co=256
set laststatus=2
set noshowmode
set fillchars+=stl:\ ,stlnc:\

However, when I run vim, I am greeted with box symbols instead of arrows, as shown below (taken from this SO question).

I have tried to switch the fonts around, and have used all of the fonts available from powerline-fonts, but there is never any difference. In fact, changing guifont to Wingdings:h14 has no effect.

How do I check that vim can support powerline? How may I get fonts working correctly? Thanks.

回答1:

Short Answer: change the terminal font if running vim in a console (guifont does nothing).

Longer Answer:

In vim --version I've discovered the line: Huge version without GUI.

Opening vim and checking :help guifont further shows that the option is {only available when compiled with GUI enabled}.

When running vim directly in a console, such as Terminal, vim does not have the ability to control the font, as discussed in the comment section here. In this instance, the solution to my problem is simply to change the font of the entire console, available in Terminal under Preferences->Settings->Text.

It is possible to compile vim via Macports with +gtk2, but I was unable to get guifont to have any effect.

Hope this helps others avoid a simple mistake.



标签: macos vim fonts