Is there any way to use a non-monospace font in either vim or gvim?

I tried changing the font for gVim with:

:set guifont=Dejavu\ Serif\ 12

But this gives me some rather ugly results:

enter image description here

I get the same results if I use the menu (Edit -> Select font)

:help guifont says:

width).  An exception is GTK 2: all fonts are accepted, but
mono-spaced fonts look best.

So I think the above results count as "not looking best"? Can this be improved upon, somehow?

I also tried setting a non-monospace font in my terminal (xterm), but that seems to have roughly the same effect:

enter image description here

I don't mind using a different terminal emulator for this btw.

  • it looks it has already been answered here: superuser.com/questions/357571/… – guido Feb 8 '15 at 6:20
  • 1
    @guido I don't see an answer there ... The most upvoted answer is just an explanation of what fonts are (not an answer), and the other "answers" are even worse... – Martin Tournoij Feb 8 '15 at 21:39

I found mlterm, which supports this. Aside from Emacs' built-in terminal (M-x term) this is the only terminal I've found that supports this (I've tried about 15-20 different ones).
I've found that mlterm works better than Emacs due to the sceen ratio settings, and you also avoid having to run Vim inside an Emacs session (I'm not even sure that is legally allowed).

Screenshot (it looks ugly unless you open it full size due to scaling in the browser):

enter image description here

It does require some configure love, though. After starting, press Ctrl + middle click anywhere, this will open the configure screen. I set these options

In the Font tab:

  • Check "Anti-alias"
  • Check "Variable column width"; this is the "key feature" missing from most other terminal emulators
  • Set font to "DejaVu Sans Book 16" (or whatever else you prefer)
  • Set "screen ratio against font size" width to 60; this lies to programs about the width of the terminal, of you don't do this, you're only using ~50% of the screen size. The best value for this depends on the font used, so experiment a bit...

The Right-click configure screen seems a bit flaky, I also edited my ~/.mlterm/vaafont since this wasn't updated:

ISO10646_UCS4_1 = 22,DejaVu Sans 18;21,DejaVu Sans 16;16,DejaVu Sans 16

And my ~/.mlterm/main (these are the settings I set above, plus some personal preferences):

type_engine = xft
bel_mode = none
scrollbar_mode = none
fontsize = 22
use_anti_alias = true
use_variable_column_width = true
line_space = 5
use_multi_column_char = true
col_size_of_width_a = 1
screen_width_ratio = 50

There are some artefacts, which are to be expected, but writing emails or posts such as this, it seems to work quite well!

I created an alias in my shell for this:

alias pvim mlterm -e vim

I also created a little function to remove most UI chrome:

fun! WriteMode()
    " Disable a lot of stuff
    setlocal nocursorline nocursorcolumn statusline= showtabline=0 laststatus=0 noruler

    " Hack a right margin with number
    setlocal number
    setlocal numberwidth=3

    " White text, so it's 'invisible'
    highlight LineNr ctermfg=15
    " If you're using a black background:
    " highlight LineNr ctermfg=1

There's also goyo.vim which goes roughly the same, but that didn't work very well for me (too much mucking about with margins). YMMV though.

  • I had to use Ctrl+RightClick, not middle on Ubuntu 18.04 with MLTerm from the Ubuntu repos. Otherwise I only get some strange square frame around mouse cursor and no dialog. – Ruslan May 22 at 8:18
  • Looks funny (and unusable) when you use vertical split: screenshot. But that's to be expected from a terminal-based solution. – Ruslan May 22 at 8:27

It's definitely not supported in GUI Vim, and I'd be surprised if there were more than handful of terminal emulators that support proportional fonts in the way that you're hoping for: it would break too many of the standard things for which terminals are used. As so many parts of Unix and other command-line environments presume monospaced fonts, this type of display couldn't be used as a general purpose terminal, so the terminal's developer would have to have carried out additional work for little benefit.

However, there does exist at least one Terminal emulator that's implemented using web technologies (Ajaxterm), and as this uses HTML/CSS for rendering, it's possible to make it to use a proportional font using CSS. CJS Hayward has done just this, but it requires using a very old browser.

If you were to run Vim in such a terminal, then you'd get what you're asking for; just be prepared for wacky hijinx when you use any column-based features. (e.g. j, k, blockwise visual mode, or the 'colorcolumn' option)

UPDATE As original question-asker Carpetsmoker points out in a comment, Emacs has proper proportional font support and also includes a terminal emulator (M-x term), inside which you can run Vim. Dedicated proportional-font enthusiasts might also like to look into Emacs's Evil to get a Vim-like experience within Emacs.


Proportional fonts are supported in Oni, Neovim GUI. Use the "webgl" renderer for best results.

 "editor.renderer": "webgl"

See also https://github.com/onivim/oni/issues/2359

Your Answer

