wide letter spacing when using gvim (GUI mode)

2,744 views
Skip to first unread message

Alex Dong Li

unread,
Feb 20, 2013, 11:23:52 AM2/20/13
to v...@vim.org
Dear Vim Experts,

I have a quick question:
when I use vim in an xterm, everything looks fine. However, when I use gvim (GUI mode), the space between letters is big and wide. Is there a way to make gvim display the text in vim (non-GUI) way? Tried different ways to solve the issue such as changing font or size but they do not work.

I am using gvim v7.2 that comes with redhat distribution.

Thanks in advance!

Alex Li

Ben Fritz

unread,
Feb 20, 2013, 1:06:09 PM2/20/13
to vim...@googlegroups.com, v...@vim.org, alexd...@gmail.com
I've never seen this problem on Windows or Ubuntu. Can you supply a screenshot? What font are you using? Does that font not show big spaces in other applications? Is it the same as the font used by your xterm? Is it all letters or just some of them? If it's just some of them, which ones? The only setting I know of that affects character width is 'ambiwidth' but I may be missing some, and that only affects some characters.

John Little

unread,
Feb 20, 2013, 1:25:40 PM2/20/13
to vim...@googlegroups.com
That's what you get if you use a non-monospace font with the GTK2 build of vim (that build is the default). Try switching to a font that has "mono" in its name.


Regards, John Little

Sven Guckes

unread,
Feb 20, 2013, 1:29:04 PM2/20/13
to v...@vim.org
* Alex Dong Li <alexd...@gmail.com> [2013-02-20 19:14]:
> Dear Vim Experts, I have a quick question:
> [I am using gvim v7.2 that comes with redhat distribution.]
>
> when I use vim in an xterm, everything looks fine.
> However, when I use gvim (GUI mode), the space
> between letters is big and wide. Is there a way to
> make gvim display the text in vim (non-GUI) way?
>
> Tried different ways to solve the issue such
> as changing font or size but they do not work.

can you make the problem visible to us by
taking a screenshot and posting its link?

which monospaced fonts have you tried?

courier, monaco, profont... Bitstream Vera Sans Mono?
Inconsolata?: http://levien.com/type/myfonts/inconsolata.html
TheSansMono?: http://www.fontfabrik.com/fofafon4.html

more info, please!

Sven

Alex Dong Li

unread,
Feb 20, 2013, 1:48:28 PM2/20/13
to vim...@googlegroups.com
Dear Sirs,

I am adding more details to my problem.

I use monospace. I access gvim using xterm via reflectionX (an xterm app). I am attaching two files vim.png and gvim.png generated using the same vimrc and the same xterm. You will immediately see what I mean. Now I know it probably has something to do with guifontwide, but just cannot get the problem solved. 
My .vimrc file is simple:
" set fileencodings=latin1          " tried this too but it does not work.
set hlsearch
set cinoptions=:0,p0,t0
set cinwords=if,elsif,else,while,do,for,switch,case,foreach,unless,until
set guifont=Monospace\ 8
"set guifontset=Monospace \8      " tried this too but it does not work
"set guifontwide=Monospace\ 8    " tried this too but it does not work.

Here is vim detail:
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Feb 17 2012 10:22:22)
Included patches: 1-411
Modified by <bugz...@redhat.com>
Compiled by <bugz...@redhat.com>
Huge version with GTK2 GUI.  Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent +clientserver
+clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +cryptv +cscope +cursorshape
 +dialog_con_gui +diff +digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search
+farsi +file_in_path +find_in_path +float +folding -footer +fork() +gettext -hangul_input
+iconv +insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds
+localmap +menu +mksession +modify_fname +mouse +mouseshape +mouse_dec +mouse_gpm
-mouse_jsbterm +mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme
 +netbeans_intg -osfiletype +path_extra +perl +postscript +printer +profile +python
+quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent -sniff +startuptime
+statusline -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white -tcl +terminfo
+termresponse +textobjects +title +toolbar +user_commands +vertsplit +virtualedit +visual
+visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup +X11 -xfontset
+xim +xsmp_interact +xterm_clipboard -xterm_save
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "/etc/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -I/usr/include/gtk-2.0 -I/usr
/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -
I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/f
reetype2 -I/usr/include/libpng12     -O2 -g -pipe -Wall  -fexceptions -fstack-protector --par
am=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64  -D_FORTIFY_SOU
RCE=1    -D_REENTRANT -D_GNU_SOURCE  -fstack-protector -I/usr/local/include -D_LARGEFILE_SOUR
CE -D_FILE_OFFSET_BITS=64  -I/usr/lib64/perl5/CORE  -I/usr/include/python2.6 -pthread
Linking: gcc   -Wl,-E -Wl,-rpath,/usr/lib64/perl5/CORE   -L/usr/local/lib -o vim   -lgtk-x11-
2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcair
o -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0   -lXt -lselinux
  -lncurses -lacl -lgpm   -Wl,-E -Wl,-rpath,/usr/lib64/perl5/CORE  -fstack-protector  -L/usr/
lib64/perl5/CORE -lperl -lresolv -lutil -lc -L/usr/lib64/python2.6/config -lpython2.6 -lutil
-lm -Xlinker -export-dynamic


Thanks!

Alex


On Wed, Feb 20, 2013 at 12:25 PM, John Little <John.B...@gmail.com> wrote:
That's what you get if you use a non-monospace font with the GTK2 build of vim (that build is the default).  Try switching to a font that has "mono" in its name.


Regards, John Little

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



gvim.png
vim.png

Tony Mechelynck

unread,
Feb 20, 2013, 1:58:07 PM2/20/13
to vim...@googlegroups.com
On 20/02/13 19:25, John Little wrote:
> That's what you get if you use a non-monospace font with the GTK2 build of vim (that build is the default). Try switching to a font that has "mono" in its name.
>
>
> Regards, John Little
>

�or a font with "Courier" "Console" "Fixed" or "Typewriter" in its name:
examples:

Bitstream Vera Sans Mono
DejaVu Sans Mono
Luxi Mono
Mitra Mono
Monospace

Courier New
Courier New KOI-8

Misc Console

Misc Fixed

Lucida Sans Typewriter


I don't recommend Lucida if you have (or could have) text with bold
Cyrillic text: in my experience, such glyphs are one pixel too wide in
that font.


Best regards,
Tony.
--
Why does New Jersey have more toxic waste dumps and California have
more lawyers?

New Jersey had first choice.

Ben Fritz

unread,
Feb 20, 2013, 2:27:13 PM2/20/13
to vim...@googlegroups.com, alexd...@gmail.com
On Wednesday, February 20, 2013 12:48:28 PM UTC-6, alexdongli wrote:
> Dear Sirs,
>
>
> I am adding more details to my problem.
>
>
> I use monospace. I access gvim using xterm via reflectionX (an xterm app). I am attaching two files vim.png and gvim.png generated using the same vimrc and the same xterm. You will immediately see what I mean. Now I know it probably has something to do with guifontwide, but just cannot get the problem solved. 
>
> My .vimrc file is simple:
>
> " set fileencodings=latin1          " tried this too but it does not work.
> set hlsearch
>
> set cinoptions=:0,p0,t0
> set cinwords=if,elsif,else,while,do,for,switch,case,foreach,unless,until
>
> set guifont=Monospace\ 8
>
> "set guifontset=Monospace \8      " tried this too but it does not work
> "set guifontwide=Monospace\ 8    " tried this too but it does not work.
>
>
>

Thanks, those details and the screenshots help a lot.

I'm not 100% certain your "set guifont" line in your .vimrc is doing what you want; the exact string needed depends very much on your system.

Can you try, from gvim, the following command to select a font?

:set guifont=*

This should bring up a dialog where you can choose a font from a list of supported fonts and sizes.

If selecting a font in this way makes your issue go away, do:

:set guifont?

or

:echo getfontname()

to see what string you should put in your .vimrc to set the font permanently.

See http://vim.wikia.com/wiki/Change_font if any of this confuses you.

Alex Dong Li

unread,
Feb 20, 2013, 3:21:54 PM2/20/13
to Ben Fritz, vim...@googlegroups.com
Ben,

I tried and 4 fonts showed up: DejaVu Sans, Monospace, Sans, Serif, same as if I use GUI's menu to set the font. I have tried each of them but it does not work either.
I wishes I had the root access to our company linux servers so that I could compile vim with multi-byte disabled. Too many libraries/headers are missing for me to compile gvim myself.

Thank you very much for your help anyway!

Alex.

Ben Fritz

unread,
Feb 20, 2013, 4:38:03 PM2/20/13
to vim...@googlegroups.com, Ben Fritz, alexd...@gmail.com
On Wednesday, February 20, 2013 2:21:54 PM UTC-6, alexdongli wrote:
> Ben,
>
>
> I tried and 4 fonts showed up: DejaVu Sans, Monospace, Sans, Serif, same as if I use GUI's menu to set the font. I have tried each of them but it does not work either.
>
> I wishes I had the root access to our company linux servers so that I could compile vim with multi-byte disabled. Too many libraries/headers are missing for me to compile gvim myself.
>
>
> Thank you very much for your help anyway!
>

There should be absolutely no need to strip out multibyte support. Thousands of people use gvim with multibyte every day without ever seeing your issue.

Can you please respond with what font name Vim is actually using, the output of :set guifont? and :echo getfontname() as I mentioned before? We may still be able to help.

Tony Mechelynck

unread,
Feb 20, 2013, 5:54:48 PM2/20/13
to vim...@googlegroups.com
On 20/02/13 21:21, Alex Dong Li wrote:
> Ben,
>
> I tried and 4 fonts showed up: DejaVu Sans, Monospace, Sans, Serif, same
> as if I use GUI's menu to set the font. I have tried each of them but it
> does not work either.
> I wishes I had the root access to our company linux servers so that I
> could compile vim with multi-byte disabled. Too many libraries/headers
> are missing for me to compile gvim myself.
>
> Thank you very much for your help anyway!
>
> Alex.

If ":set gfn=*" shows only those four and nothing else (and no way to
scroll to bring more font names into view) and what is called Monospace
on your computer is what you showed in the gvim screenshot, then it
means there is _no_ monospaced font on your computer that gvim can see
(that font in the gvim screenshot isn't a monospace font: it's a
proportional sans-serif font, maybe "DejaVu Sans" but not "DejaVu Sans
Mono" which would be the "real" monospaced font in the same family).

So, you could either complain to your sysadmin, that there is no
fixed-width typewriter-like font that you can reach from gvim�

�or use console vim. Or, on Linux, use gvim in console mode by means of
a softlink, to make sure you have a full-featured Console Vim with X11
support:

pushd ~/bin
ln -sv `which vim` vim-orig
ln -sv `which gvim` vim
popd


Best regards,
Tony.
--
"All my friends and I are crazy. That's the only thing that keeps us
sane."

Alex Dong Li

unread,
Feb 20, 2013, 6:27:04 PM2/20/13
to vim...@googlegroups.com
I think Tony has got the point: Monospace on my system is a proportional font, not a width-fixed font. Sorry for my wrong assumption! As matter of the fact, I do not have any width-fixed fonts available to gvim.

Thank everyone who has helped very much! Also sorry for sending file attachments to everyone!

Alex.

John Little

unread,
Feb 20, 2013, 7:59:43 PM2/20/13
to vim...@googlegroups.com, Ben Fritz, alexd...@gmail.com
On Thursday, February 21, 2013 9:21:54 AM UTC+13, alexdongli wrote:
> I wishes I had the root access to our company linux servers so that I could >compile vim with multi-byte disabled. Too many libraries/headers are missing >for me to compile gvim myself.

You don't need root access to install a font for your own use.
- Download a .ttf or .otf to wherever.
- With KDE, open it with kfontviewer, click install, click personal.
- With Gnome3, I think nautilus has support. Gnome 2 had gnome-font-viewer.

This just copies the font file to .fonts in your home directory, in a directory whose name is the first letter of the font file name. I just downloaded monofur.ttf, and copied it to ~/.fonts/m, and gvim found it without further ado. (Unpleasant font, IMO).

Regards, John Little

Reply all
Reply to author
Forward
0 new messages