Set MacVim default font

VimFontsDefault

Vim Problem Overview


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.

Vim Solutions


Solution 1 - Vim

Place this in .gvimrc:

set guifont=Monaco:h12

Note the lack of spaces around the equals sign.

Solution 2 - Vim

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

set guifont=Fira\ Code:h12

Solution 3 - Vim

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 - Vim

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 - Vim

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

set gfn=Monaco:h13
set linespace=2

Solution 6 - Vim

To deal with not just English characters, you can put this in your .vimrc file (guifontwide deals with Chinese characters):

if has("gui_running")
    set guifont=Consolas:h14
    set guifontwide=Hiragino\ Sans\ GB
    set linespace=2
endif

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKitView Question on Stackoverflow
Solution 1 - VimKitView Answer on Stackoverflow
Solution 2 - VimNew AlexandriaView Answer on Stackoverflow
Solution 3 - VimBenjaminView Answer on Stackoverflow
Solution 4 - VimChu-Siang LaiView Answer on Stackoverflow
Solution 5 - VimFarshid AshouriView Answer on Stackoverflow
Solution 6 - VimHustlionView Answer on Stackoverflow