Solved VIM - set guifont

OS = FreeBSD-12.2p3
vim = 8.2.2263

In .vimrc I would like to change the guifont in vim on the mate desktop from this: :set guifont=Bitstream\ Vers\ Sans\ Mono\ 14\ cANSI;

to this: :set guifont=DejaVu\ Sans\ Mono\ 14\ cANSI

However while the Bitstream setting works as documented: guifont=Bitstream Vers Sans Mono 14 cANSI the DejaVu does not: guifont=.

I can set the font to DejaVu from within gvim (guifont=DejaVu Sans Mono 14), but I would like it to just open in that font. I cannot see what it is that I am doing wrong. What is stopping gvim recognizing the DejaVu setting?
 
I have never used .gvimrc on any system and I have not run into any difficulties before this. And there are two things that tell against this solution.

First, I created a .gvimrc file with a single setting: :set guifont=DejaVu\ Sans\ Mono\ 16\ cANSI and then commented out the :set guifont= settings in .vimrc. This is the result:

guifont=

Second, I note that every other setting in .vimrc are picked up and used by gvim. Including the Bitstream specification, as I can change the font size in that and gvim picks up the change when restarted.

:set guifont=Bitstream\ Vers\ Sans\ Mono\ 18\ cANSI

results in:

guifont=Bitstream Vers Sans Mono 18 cANSI

SO there has to be something else at work which causes this problem.
 
Remove the colon from :set, it's just set in .vimrc/.gvimrc.

Second, I note that every other setting in .vimrc are picked up and used by gvim.
That's correct. gvim(1) reads both. But because the guifont has no use in vim(1) it should go in .gvimrc.

Code:
       /usr/local/etc/vim/vimrc
                      System wide Vim initializations.

       ~/.vimrc       Your personal Vim initializations.

       /usr/local/etc/vim/gvimrc
                      System wide gvim initializations.

       ~/.gvimrc      Your personal gvim initializations.
From gvim(1)

You can add it in .vimrc but you need to take care of of setting only when the GUI is running:
Code:
if has('gui_running')
  set guifont=Lucida_Console:h11
endif

 
I use the if has('gui_running') ideom. I worked for me for the past decade or so and I do not need to remember to look in yet another configuration file. In any case, neither work as expected or I have a syntax error that I do not recognize.
 
I am familiar with the set item? syntx and how to get it to display with the escapes ( :set guifont=<tab><cr>). But the string that is displayed does work when I reproduce it in .vimrc.
 
The problem was that I forgot that .vimrc requires " as a comment marker and not #. So the commented guifont settings were not. This caused vim to resolve the resulting conflict by falling back to the default.
 
Back
Top