|Code Yarns 👨💻|
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
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.
" This works on Windows, but is ineffective on Linux set guifont="Ubuntu Mono 10" " This works on Linux set guifont=Ubuntu\ Mono\ 10
Tried with: Vim 7.4 and Ubuntu 14.04