Vim Recipes GUI (GVim) Changing the Font

Changing the Font

Problem

You want to display the text in a different font.

For example, the current font isn't particularly readable, or is too large.

Solution

Standard Vim uses the font from the terminal it is run under. Gvim, however, gives you full control over the font face and size.

The command :set guifont font-name changes the current font to font-name. The font name can be followed by a size. There are, unfortunately, some platform-specific differences at this point…

Specifying guifont in an Operating-System-Specific Manner

Linux

For example: :set guifont=Andale\ Mono\ 11.

Mac

For example: :set guifont=Monaco:h11.

Windows

For example: :set guifont=Andale_Mono:h11.

Discussion

To change the font you need to know its name. On most operating systems you can request a GUI font chooser with the command :set guifont=*. Linux users can also use the xlsfonts utility to see a list of available fonts.

If the font you've specified can not be found, Vim complains. To avoid this you can specify multiple fonts in order of preference with a comma separated list. The first valid font is loaded. For example: :set guifont=Screen15,\ 7x13. This approach is particularly useful if you use your Vim configuration on multiple computers, or if you simply want it to be portable.