Old Guy New Trick

An old guys journey to learn how to code.

Gooey Vim


Author: John on November 04, 2015

Today I'd to visit vims' cousin, MacVim.  While I do spend most of my time in what I will call "normal" vim, that is vim executed from the command line of my terminal (iTerm), there are times when I want to work in MacVim.  I tend to reserve MacVim to acts as my general use notepad.  The main reason I treat it as a scratch/notepad instead of vim, is that I find copying and pasting to be more user friendly with MacVim.  There are some other aspects I like, for example being able to scroll using the trackpad on my laptop or via the scroll wheel on a mouse.

While watching some episodes of Elixir Sips and LearnElixir I noticed that the presenters had a pretty cool setup in vim.  I did a little research and found that they use a plugin similar to Airline.  The plugin, and ones similar to it, dress up your vim environment.  So I installed one of the plugins, *bling/vim-airline* and ran into issues with the display - it was a little bit off.  Through more research, I discovered that I needed to install the Powerline family of fonts.  Once that was completed my vim environment looked awesome. 

However, when I launched MacVim, I was having issues.  Back to the web and more reading.  I found that I needed to update my gvimrc file to setup the use of a guifont. Initially I tried updating the gvimrc and set the following:

set guifont=Source\ Code\ Pro\ Powerline:14

I tried a few different combinations, with out success.  So I decided to play around a bit.  First I launched MacVim (mvim).  Then I tried to manually set the font using:

:set guifont=SourceCodeProforPowerline -> didn't work
:set guifont=Source\ Code\ Pro\ for\ Powerline:14 -> didn't work

I stumbled upon a answer over at StackOverflow and noticed that the poster included an 'h' just before the font size.  So I gave that a try:

:set guifont=Source\ Code\ Pro\ for\ Powerline:h14  -> WORKED!

Cool, I got that to work.  But dang, I don't want to have to type that everytime I launch MacVim and want my environment to be all gooey-fied.  So I decided to make a modification to my .vimrc file:

" set a guifont for MacVim and Powerline Font support
" You can now use Cntrl+g to turn on the font setting below
nnoremap  :set guifont=Source\ Code\ Pro\ for\ Powerline:h14

Tip: You can also use this format:
set guifont=Source_Code_Pro_for_Powerline:h14 

While I like, and use the Cntrl+g option as indicated above, my stubbornness really wanted to get the font working via an update to the gvimrc file.  Once I saw, through my trial and errors above, what MacVim was looking for in the ways of proper syntax, I re-visited updating the gvimrc file.  So I added the following to my gvimrc file and restarted MacVim:

set guifont=Source_Code_Pro_for_Powerline:h14 

#NOTE: You can put the above in either ~/.gvimrc 
#      OR 
#      /Applications/MacVim.app/Contents/Resources/vim/gvimrc

And BAM! my nice gooey font setting was applied.


Learn Something New Every Day

Last Edited by: John on December 13, 2016