设置 MacVim 默认字体

如何设置 MacVim 的默认字体?

我尝试添加以下代码行

set guifont = Monaco:h12

下列任何一个档案:

~/.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

我重新启动了 MacVim,但它仍然无法设置默认字体。我遗漏了什么吗?

更新: 我可以在运行时发出 set guifont命令,它工作得很好。只是从我的启动文件上看不出来。

45212 次浏览

Place this in .gvimrc:

set guifont=Monaco:h12

Note the lack of spaces around the equals sign.

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

set guifont=Fira\ Code:h12

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.

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

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

set gfn=Monaco:h13
set linespace=2

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