set gvim font in .vimrc file
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 endifendif
Edit: And while you're at it, you could take a look at Coding Horror's Programming Fonts blog post.
Edit²: Added MacVim.
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
.