Following the answers in I have tried many varieties of setting the font size and face in ~/.vimrc . None of them have any effect

set guifont=Menlo:h12
set guifont=Monaco:h12
set guifont=Menlo\ Regular:h12

Note that executing

:set gfn=*

does bring up a font chooser dialog - and I am able to choose either Monaco or Menlo or many others correctly. But I don't want to have to choose every time - thus the ~/.vimrc . What might be wrong how to fix this?

  • The font names are system-dependent. Make sure you write it in a right way. First, type :set gfn=* to choose one. Then see an exact name with :set gfn?
    – Matt
    Dec 22, 2019 at 5:42
  • Thx Matt Monaco and Menlo do show up in the dialog - as alluded in the actual question above. Dec 22, 2019 at 5:49
  • I mean what :set gfn? exactly shows after you've selected one of them? Could be, for example, "Menlo 12" instead of "Menlo:h12" etc.
    – Matt
    Dec 22, 2019 at 5:52
  • guifont=Menlo Regular:h14 is what shows up without actually manually setting one of the fonts. If I select one of the fonts from the chooser that does set it properly. But the question above is about avoiding that for each file Dec 22, 2019 at 6:02
  • set guifont=Menlo\ Regular:h12 works fine for me in my .vimrc. Does it work for you if you run it manually from the command-line after start up? I presume other settings in your vimrc are taking effect? What's the output of :verbose set guifont? after start up?
    – Rich
    Jan 21, 2020 at 16:45

4 Answers 4


Since font is specific to the GUI versions of vim (i.e. gvim and macvim), you need to should put the set guifont=... line in your gvimrc.

A good place for that is ~/.vim/gvimrc, but you can read help gvimrc for locations.

According to setting-guifont:

When you use the same vimrc file on various systems, you can use something
like this to set options specifically for each type of GUI:

if has("gui_running")
  if has("gui_gtk2")
    :set guifont=Luxi\ Mono\ 12
  elseif has("x11")
    " Also for GTK 1
    :set guifont=*-lucidatypewriter-medium-r-normal-*-*-180-*-*-m-*-*
  elseif has("gui_win32")
    :set guifont=Luxi_Mono:h12:cANSI
  elseif has("gui_macvim")
    :set guifont=DejaVu\ Sans\ Mono:h13

So this would indicate guifont should be set only when has('gui_running') is true—i.e., when the gui is started or about to start.

I can't find anything that requires this in help macvim, help gui, or help gui-init.

  • 1
    Sounds plausible... Unfortunately I didn't find anything in the docs to confirm this is actually the case... Do you happen to have any corroborating sources? Or some other indication that this (or similar GUI settings) won't work when set from vimrc, but will from gvimrc?
    – filbranden
    Dec 22, 2019 at 8:08
  • 2
    AFAIK, you can't directly use set gfn=... and such in vimrc only if GUI load is delayed, like in Neovim, for example.
    – Matt
    Dec 22, 2019 at 8:12
  • 1
    @filbranden I can't find anything that requires it, but it is definitely preferred. It works for me like that, at least.
    – D. Ben Knoble
    Dec 22, 2019 at 15:57

I had the same problem as the OP after upgrading from Ubuntu 16.04 to 18.04. Turns out the condition if has("gui_gtk2") in _vimc is no longer true, changed it to "gui_gtk3" as a wild guess and bingo! my fonts settings are working again.


Create/modify a file called.gvimrc in your home directory and add set guifont=DejaVu\ Sans\ Mono\ Book\ 12. Restart gvim to take effect.


You may find useful this plugin I made to simplify setting guifont in a portable way: https://github.com/awvalenti/vim-simple-guifont. Your vimrc goes like this and it handles all the OS specific stuff:

silent! call simple_guifont#Set(
  ['Cascadia Code PL', 'JetBrains Mono', 'Hack'], 'Consolas', 14)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.