Tim Johnson wrote:
Hello:
I'm using vim compiled as 'vim.full' for kubuntu 7.04 amd-64.
I used vim extensively for programming for years, and am now
getting "back into it".

When I start vim, I see a font that I really like, but I would like to make the font smaller. The problem is that when I choose
Edit -> Select Font - the font that is highlighted is "Sans" and when I
choose the font size, the font that is loaded is very different from what
was installed when i started and is far from appealing.
I appreciate some tips as how to resolve this.
thanks
timf


To change the font size without changing the font face (in 'nocompatible' mode):

        :set guifont=<Tab>

where <Tab> means "hit the Tab key". Vim will fill in the current value (which may be empty if it is still the default) with escaping backslashes if and where needed. You can edit it in place, then hit <Enter> to accept the new value (or <Esc> to abort).

If the value is empty, you'll have to do something else to find the real value, see furter down this post.

If the value is not empty, it can still be in various formats depending on your GUI version. If there is only one number, that's the size. If there are several... well... one of them is usually the size. Here are a few examples:

GTK2 (but not GTK1):
        :set guifont=Bitstream\ Vera\ Sans\ Mono\ 11
... the size is 11 (pt).

kvim (obsolete):
        :set guifont=Bitstream\ Vera\ Sans\ Mono/9/-1/5/50/0/0/0/1/0
... the size is 9 (pt). Keep the rest unchanged.

Photon:
        :set guifont=Bitstream\ Vera\ Sans\ Mono:s9
... the size is 9 (pt).

Other X11 versions (including GTK1):
        :set guifont=-*-lucidatypewriter-medium-r-normal-*-*-100-*-*-m-*-*
... the size is 100 (meaning, IIUC, 10.0pt).

Other (e.g. Windows):
        :set guifont=Courier_New:h12:cDEFAULT
... the size is 12 (pt).

In all cases, decrease the size to make the font smaller. For "other-x11" there is a hitch: height, or width, or both, may be specified. If the height changes but the width doesn't, replace all numbers other than the height (as shown above) by a single asterisk apiece.

If the current value is empty, some GUI "flavours" will accept

        :set guifont=*

to set it via a menu. You'll have to find a font face that you like, and set the size too.

If ":set guifont=*" doesn't work on your version, then you can either recompile with GTK2 (which does accept that command), or use the following code snippet to set a nonempty value acceptable to your particular gvim flavour:

if has("gui_running")
        if has("gui_gtk2")
                set gfn=Bitstream\ Vera\ Sans\ Mono\ 9
        elseif has("gui_photon")
                set gfn=Bitstream\ Vera\ Sans\ Mono:s9
        elseif has("gui_kde")
                set gfn=Bitstream\ Vera\ Sans\ Mono/9/-1/5/50/0/0/0/1/0
        elseif has("x11")
                set gfn=-*-lucidatypewriter-medium-r-normal-*-*-100-*-*-m-*-*
        else
                set gfn=Lucida_Console:h9:cDEFAULT
        endif
endif

Place it in your vimrc. Then you can tweak it by command-line editing (using ":set gfn=<Tab>", edit-in-place, then Enter). You will, however, have to "guess" the font face name if you want something else than what was set (or if the above tries to set a font face which doesn't exist on your computer). (If you have a program which can set the font via a font chooser menu, you can use that to see which fonts are available, but remember that gvim can only use "fixed-width" aka "monospace" fonts -- except in GTK2, where ":set gfn=*" is legal anyway.)

Once you decide that you've found "something you like", don't forget to insert the new value at the appropriate place in the vimrc. (You can always use ":set gfn=<Tab>", in 'nocompatible' mode, to see what you must use).


Best regards,
Tony.
--
   They now pass three KNIGHTS impaled to a tree.  With their feet off the
   ground,  with one lance through the lot of them, they are skewered up
   like a barbecue.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

Reply via email to