vimx11

Settings default font in gvim


I'm using gvim (vim -g). I want to set default font to be Monaco.

Here is the content of my .vimrc

if has("gui_running")
    if has("gui_gtk2")
         set guifont=Monaco\ New\ 11
       elseif has("gui_photon")
         set guifont=Monaco\ New:s11
       elseif has("gui_kde")
         set guifont=Monaco\ New/11/-1/5/50/0/0/0/1/0
       elseif has("x11")
         "set guifont=-*-courier-medium-r-normal-*-*-180-*-*-m-*-*
         set guifont=Monaco:h11:cDEFAULT

       else
         set guifont=Monaco:h11:cDEFAULT
     endif
  endif

When I start gvim the font is not Monaco


Solution

  • The easiest way of setting the 'guifont' is simply not bothering with the exact font string at all.

    Use a friendly dialog to set it instead:

    :set guifont=*
    

    This pops up a dialog where you can select your preferred font.

    Once you have set it, you can query the setting again with

    :set guifont?
    

    and put that string in your vimrc. On my machine this returns Monaco:h12 for Monaco at 12pt. Make the change at the appropriate place in your block, or, if you have no idea what you're doing, simply replace the whole block with

    if has("gui_running")
      set guifont=Monaco:h12
    endif