On Windows 10, I had to add this line to _vimrc in user home directory to make font setting persistent: (Default set to Consolas size 10).
GVIM also reads your ~/. vimrc ; most of the configuration belongs there, and only there. Only configuration exclusive to the GUI should be placed in the ~/.
Console Vim uses whatever font the console/terminal is using. Changing the font in your terminal is done differently depending on your system and the terminal in use.
You can use :set command to list all settings and put it to ${HOME}/.
I use the following (Uses Consolas size 11 on Windows, Menlo Regular size 14 on Mac OS X and Inconsolata size 12 everywhere else):
if has("gui_running")
if has("gui_gtk2")
set guifont=Inconsolata\ 12
elseif has("gui_macvim")
set guifont=Menlo\ Regular:h14
elseif has("gui_win32")
set guifont=Consolas:h11:cANSI
endif
endif
Edit: And while you're at it, you could take a look at Coding Horror's Programming Fonts blog post.
Edit²: Added MacVim.
Try setting your font from the menu and then typing
:set guifont?
This should display to you the string that Vim has set this option to. You'll need to escape any spaces.
I am trying to set this in .vimrc file like below
For GUI specific settings use the .gvimrc
instead of .vimrc
, which on Windows is either $HOME\_gvimrc
or $VIM\_gvimrc
.
Check the :help .gvimrc
for details. In essence, on start-up VIM reads the .vimrc
. After that, if GUI is activated, it also reads the .gvimrc
. IOW, all VIM general settings should be kept in .vimrc
, all GUI specific things in .gvimrc
. (But if you do no use console VIM then you can simply forget about the .vimrc
.)
set guifont=Consolas\ 10
The syntax is wrong. After :set guifont=*
you can always check the proper syntax for the font using :set guifont?
. VIM Windows syntax is :set guifont=Consolas:h10
. I do not see precise specification for that, though it is mentioned in the :help win32-faq
.
:e $MYGVIMRC
Enter
:set guifont=
Tab Enter.The command in step 6 will insert the contents of the :
special register
which contains the last ex-mode command used. Here that will be the command
from step 4, which has the properly formatted font name thanks to the tab
completion of the value previously set using the GUI dialog.
For Windows do the following:
:e $MYGVIMRC
set guifont=<font name as noted>:h<font size>
Although this is an old thread I thought that I would add a comment as I have come across it whilst trying to solve a similar issue; this might help anyone else who may find themselves here:
The backslash character is used to ignore the next character; once added to the font name in my gvimrc it worked; I am on a GNU/Linux machine which does not like spaces. I suspect that the initial post was an error due to the back slash being used on a windows machine.
In example:
:set guifont? ## From gvim command, would give the following:
set guifont=DejaVu Sans Mono for Powerline 11
Where as I needed to add this line to the gvimrc file for it to be read:
set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 11
I had to end up doing
:set guifont=Courier:h10:cANSI
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With