Vim GUI Font Magic

Yesterday, Wayne tweeted this:

@erochest just dropped some vim wizardry on the @scholarslab: open system fonts, set the guifont from the settings selected in gui

I thought I should describe what I did, for several reasons. First, it’s kind of cool, in a geeky vim-lover kind of way. Second, it’s not something you do everyday, so it’s helpful to have it written down. I’m pretty surprised that I remembered it as quickly as I did.

Step 1: Select the Font Using the Standard Font Dialog

In Vim, pop open the GUI to select the font by typing in this command: :set guifont=*. It should open up the standard font dialog box for your platform.

Select the font you want to use and close the dialog.

Step 2: Add the Font to Your .vimrc file.

Now you need to make the change permanent by adding it to your .vimrc file.

Open this file using the command :e ~/.vimrc (on Linux, UNIX, and Mac) or :e ~/_vimrc (on Windows). Then add this to the bottom:

set guifont=

At this point, you need to insert the current value of guifont. Do this by pressing Ctrl-R (while still in insert mode) and entering this in the command bar at the bottom of the screen:


Hit enter. The name and size of the font should be appended to the set guifont line you started.

If the font name has spaces, however, you’ll need to escape those. This command should do the trick:

:s/ /\ /g

Unfortunately, this does a little more than you want. It also escapes the space after set. Take that out manually.

Now, the line should look something like this:

set guifont=DejaVu Sans Mono:h13


Some nice fonts I’ve used with Vim over the years include these:

My interests include text processing, text mining, and natural language processing, as well as web-development and general programming. Studied medieval English literature and linguistics at UGA. Dissertated on lexicography. Now I program in Haskell and write when I'm not building cool stuff for the Scholars' Lab. Also, husband and parent. Do you notice that sleep…


  1. In Windows, to edit the _vimrc file, you are better off navigating to the Program Files/Vim/ folder. Copying and pasting the _vimrc file into your desktop. Editing it there. Then moving it back to the Vim folder.

  2. “And why is this relevant to the Praxis Program?” some may wonder. This is why:

    One of us will be writing about this week’s Praxis exercises (including getting started with vim) very soon!