Set MacVim default font

43,916

Solution 1

Place this in .gvimrc:

set guifont=Monaco:h12

Note the lack of spaces around the equals sign.

Solution 2

If you need to set a font with spaces in the name, use backslashes in your .gvimrc:

set guifont=Fira\ Code:h12

Solution 3

The most complete answer should be this:

set guifont=Source\ Code\ Pro\ ExtraLight:h18

I looked around and each answer and tutorial I found didn't specify how to set the typeface.

After setting your font manually using the Font window, if you are unsure exactly what to put type:

:set guifont

This will show you the exact string value you need to put in your .vimrc file, including the typeface.

Solution 4

Attach my fonts setting.

" - font type and size setting.
if has('win32')
    set guifont=Consolas:h12   " Win32.
elseif has('gui_macvim')
    set guifont=Monaco:h14     " OSX.
else
    set guifont=Monospace\ 12  " Linux.
endif

Solution 5

If you're on Mac, add these lines to your ~/.vimrc:

set gfn=Monaco:h13
set linespace=2
Share:
43,916
Kit
Author by

Kit

Updated on July 08, 2022

Comments

  • Kit
    Kit almost 2 years

    How do I set the default font for MacVim?

    I have tried adding the following line

    set guifont = Monaco:h12
    

    to either of the following files:

    ~/.vimrc
    ~/.gvimrc
    ~/Applications/MacVim/MacVim.app/Contents/Resources/vim/vimrc
    ~/Applications/MacVim/MacVim.app/Contents/Resources/vim/gvimrc
    ~/Applications/MacVim/MacVim.app/Contents/Resources/vim/.vimrc
    ~/Applications/MacVim/MacVim.app/Contents/Resources/vim/.gvimrc
    

    I restarted MacVim, but it still won't set the default font. Anything I missed?

    UPDATE: I can issue the set guifont command in runtime and it works fine. It just doesn't seem to read it off my startup files.

  • Admin
    Admin almost 11 years
    Do you use this font in general for programming?
  • New Alexandria
    New Alexandria almost 11 years
    I swear by it, yes. In addition to a 'retina display' my eye strain has dropped to nearly-zero
  • Memming
    Memming about 10 years
    you mean 'backslashes'?
  • qed
    qed almost 10 years
    what does :h mean here?
  • xji
    xji about 9 years
    Source Code Pro is wonderful! Recommend Source Code Pro Light over its regular version, though.
  • Hustlion
    Hustlion about 7 years
    You can also just put this in your .vimrc file.
  • Kit
    Kit about 7 years
    I'm guessing wide means each character is encoded by more than 8 bits, hence it's wide? Or does it actually appear wide?
  • Craig S. Anderson
    Craig S. Anderson about 5 years
    I changed to use Monaco:h12 and the torte color scheme, and it works well.
  • junhan
    junhan almost 5 years
    This is really helpful especially when you need set up powerline fonts.
  • WestCoastProjects
    WestCoastProjects over 4 years
    Having added that to ~/.vimrc there is no effect on the font actually usedin macvim