Kit
Kit

Reputation: 31523

Set MacVim default font

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.

Upvotes: 96

Views: 47337

Answers (6)

Hustlion
Hustlion

Reputation: 2373

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

Upvotes: 4

New Alexandria
New Alexandria

Reputation: 7324

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

set guifont=Fira\ Code:h12

Upvotes: 98

Farshid Ashouri
Farshid Ashouri

Reputation: 17721

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

set gfn=Monaco:h13
set linespace=2

Upvotes: 3

Chu-Siang Lai
Chu-Siang Lai

Reputation: 2728

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

Upvotes: 8

Benjamin
Benjamin

Reputation: 1862

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.

Upvotes: 28

Kit
Kit

Reputation: 31523

Place this in .gvimrc:

set guifont=Monaco:h12

Note the lack of spaces around the equals sign.

Upvotes: 143

Related Questions