How to set font in GVim


The font used by GVim can be set by choosing Edit -> Select Font, which displays a dialog to pick the font. You can get the same dialog by using the command :set guifont=*

The chosen font is used only for the current session and GVim reverts back to its default font after that.

To set the default font used by GVim, add a command of the form set guifont= to your gvimrc. If you want to add it to vimrc file, then enclose this command in a if has("gui_running") block.

The only tricky part here is, what is the format in which the font and font size should be specified? An easy trick is to set the font and font size in the font dialog and then query it back using :set guifont?. Use the exact value that it displays. Note that the format of the font string varies according to the platform. A Ubuntu Mono font in size 10 is given as Ubuntu Mono:h10 on Windows and as Ubuntu Mono 10 on Linux.

Also on Linux, note that you should not enclose the font string in single or double quotes. If the font string has spaces, then escape them using backslashes. Enclosing in quotes works fine on Windows.

Tried with: Vim 7.4 and Ubuntu 14.04


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.