Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fail to set font in Macvim

Tags:

vim

macvim

I am configuring macvim on Mac OS X Mavericks. I type "set guifont=Menlo\ 14" in both ~/.vimrc and ~/.gvimrc but the editor remains displaying in courier.

I insert ":set guifont?" and it reveals "guifont=Menlo\ 14". I overviewed the content of .vimrc and .gvimrc but found no other line overriding the guifont setting.

I have checked several posts in stack overflow but cannot yet find the solution. Wish to get some help, thanks for anticipation.

like image 406
Zelong Avatar asked Apr 24 '14 03:04

Zelong


3 Answers

The ideal way of going about doing this is by invoking the following command from vim :

set guifont=*

That will open a font selection dialog box and you can select whatever you would like there. Once done, you should then check what the option was set to by using the command you mentioned yourself :

set guifont?

Now you should put the output of that in your .gvimrc (not .vimrc) and additionally you'll need to escape the spaces like you're doing already. There might be subtle mistakes in what you're setting yourself, the font size for instance can sometimes be set in different ways.

like image 132
Dhruva Sagar Avatar answered Sep 30 '22 09:09

Dhruva Sagar


On my version of MacVim (7.4.258) and running EL Kapitan, putting

set guifont=*

in .vimrc caused MacVim to spit out the following error (when run from the command line, starting it from the Dock caused it to just not run at all):

E665: Cannot start GUI, no valid font found

So it seems the correct way is to start MacVim, use the Edit > Font > Show Font menu, pick a font, then use

set guifont?

to find the line to add to your .vimrc

Also remember to use forward slashes to escape any spaces in the font name.

like image 37
Kieran O'Neill Avatar answered Sep 30 '22 10:09

Kieran O'Neill


To change font, use Edit -> Font -> Show Fonts and selected a font.

Unfortunately this setting gets wiped out with each update of MacVim.

To have your font setting persisted in MacVim add this to your ~/.gvimrc

set guifont=Hack\ Nerd\ Font:h12
like image 43
David Ding Avatar answered Sep 30 '22 10:09

David Ding