Here is a trick what I usually do in a graphical Vim to select a nice looking font. First I interactively set the font using:
:set guifont=*
This brings up a nice dialog with all the known fonts known by gvim. So just select a nice looking font to be used and press Okay to get out of the dialog.
Now, you should have set this as your font setup by gvim and you can try it out a bit to see how satisfied you are with the font.
Once you are satisfied one needs to store that particular font in either the vimrc
or gvimrc
init file.
So to make this setting permanent, I edit the initialization file:
:e $MYVIMRC
and then I put the guifont setting there by typing this:
ilet &guifont="
CTRLR=&guifont
Enter"
This makes use of the expression register (see :h i_CTRL-R_=) to recall the guifont option setting and place it into the current position in your document.
So this will basically add the guifont setting exactly the way it is currently used by gvim and should make sure to set it correctly next time you start gvim.
Now optionally, you can add all the fancy autocommand and if statements you have seen elsewhere here around that guifont option setting and if you use different gvim builds on different systems, you need to repeat this step to get the correct value.
Here is an example of mine that I use on various systems:
if has("autocmd")
function! SetGuiFont()
if has("gui_gtk") && !(has("win32") || has("win64"))
let &guifont="Ubuntu Mono derivative Powerline 12"
elseif has("win32") || has("win64")
try
let &guifont="DejaVu_Sans_Mono_for_Powerline:h12:cANSI:qDRAFT"
catch
" font does not exists, fall back to default
let &guifont="Courier_New:h10:cANSI"
endtry
" optionally: add statements for other guis
endif
endfunction
if !exists('#VimStartup#GuiEnter')
augroup VimStartup
au!
autocmd GuiEnter * :call SetGuiFont()
augroup end
endif
endif
You can make this of course a lot more complex, depending on your needs.
:set gfn=*
to choose one. Then see an exact name with:set gfn?
Monaco
andMenlo
do show up in the dialog - as alluded in the actual question above.:set gfn?
exactly shows after you've selected one of them? Could be, for example, "Menlo 12" instead of "Menlo:h12" etc.guifont=Menlo Regular:h14
is what shows up without actually manually setting one of the fonts. If I select one of the fonts from the chooser that does set it properly. But the question above is about avoiding that for each fileset guifont=Menlo\ Regular:h12
works fine for me in my.vimrc
. Does it work for you if you run it manually from the command-line after start up? I presume other settings in your vimrc are taking effect? What's the output of:verbose set guifont?
after start up?