shawn bright wrote:
hey there all,
is there a way i can permanently set the font for gvim ?
i can't find a config file for it.
thanks
The config file for most options in Vim is $HOME/.vimrc (Unix) or $HOME/_vimrc
(Windows). For gvim, you may add a .gvimrc or _gvimrc, but some people (such
as me) prefer to put everything in the vimrc.
If you use a single vimrc on several platforms, setting the font may get
complicated, because (including obsolete versions) there are five different
incompatible formats for the 'guifont' option, and each executable accepts
only one of them. Here is what I have for version-sniffing and font-setting in
my vimrc (notice the comments, set apart by a double quote at the end of the
lines):
if has("gui_running") " font setting works only in the GUI
if has("gui_gtk2") " GTK+2 (not GTK+1)
set gfn=Bitstream\ Vera\ Sans\ Mono\ 9
elseif has("gui_photon") " Photon GUI
set gfn=Bitstream\ Vera\ Sans\ Mono:s9
elseif has("gui_kde") " the obsolete kvim
set gfn=Bitstream\ Vera\ Sans\ Mono/9/-1/5/50/0/0/0/1/0
elseif has("x11") " other X11 versions (including GTK+1)
set gfn=-*-lucidatypewriter-medium-r-normal-*-*-100-*-*-m-*-*
else " non-X11 versions
set gfn=Lucida_Console:h9:cDEFAULT
endif
endif
In some versions of gvim, you may use
:set guifont=*
to choose your font via a menu. Once you're satisfied with what you have, use
:set guifont=<Tab>
where <Tab> means "hit the Tab key", to see how it must be written into your
vimrc for this version of gvim. (It will appear with backslash escapes if and
where required). Write the value down, hit Escape, then write it at the proper
place in your vimrc.
If your version doesn't support ":set guifont=*", you can still use the code
snippet (with a lot of ifs) above, to set something that your version will
(hopefully) accept. Then edit it using ":set guifont=<Tab>" followed by
edit-in-place on the Vim command-line (Enter to accept, Escape to abort). Once
you know what you want, you can also write it into your vimrc in this case.
Best regards,
Tony.