
Can I use a non-monospaced font in either Vim or gVim? - pmoriarty
https://vi.stackexchange.com/questions/588/can-i-use-a-non-monospaced-font-in-either-vim-or-gvim
======
jypepin
I'm surprised that most comments here are just avoiding the problem saying
that nobody would want a non-monospace font in an editor, without trying to
understand the original reason for this and even think about the fact that
someone might be using vim a different way.

------
b0rsuk
Monospaced fonts also mean monospaced puctuation. Punctuation is super
important in programming languages. In human-human languages, a comma, a dot
or a semicolon is mostly just icing on the cake. There are examples where it
can completely change the meaning of a sentence, but for most part puctuation
errors are easy to spot, meaning can be inferred and it's largely a matter of
taste. In human-computer languages, a misplaced punctuation character really
shakes things up.

Summary: monospaced fonts give punctuation weight equal to words, which is how
it works in programming. I want non-alphanumeric characters like
,.;:`'"[]()}{!@#$^%%^*&() stand out. Notice how the left part of characters I
just listed are hard to distinguish at a glance? And what if I need to count
adjacent underscores, spaces or semicolons? Variable length characters are
optimised for prose and human-human communication.

~~~
genericid
Nonsense. Monospaced fonts do not give punctuation weight equal to words.
Fonts that give punctuation weight equal to words do. See for example the
Input font family:

[http://input.fontbureau.com/](http://input.fontbureau.com/)

------
ealhad
For the Emacs users wanting to try this…

    
    
      M-x variable-pitch-mode
    

Vim users, I can assure you that Evil is a really good implementation of Vim,
which happens to run in a really good environment.

~~~
pmoriarty
Unfortunately, this requires the use of gui-emacs, while my entire emacs
config is geared towards use from a terminal.

~~~
ealhad
Indeed.

------
ohhellno
I switched from vim full-time to using vscode with the vim plugin for most
things. The plugin has gotten better over time and at this point all of my
familiar bindings just work as they do in vim. Changing the font is easy.

------
ur-whale
I've never understood the attraction of non-monospaced font in an editor.

 _Especially_ when you code, where you basically read as much in the vertical
direction than in the horizontal.

Monospaced fonts allows for super-fast vertical pattern matching on the code
which helps your brain tremendously.

To me, non-monospaced font in an editor is exactly as if each letter in a line
of text was placed at a somewhat random height, a very unpleasant experience.

~~~
pmoriarty
_" I've never understood the attraction of non-monospaced font in an editor."_

I need to use some special characters which are only available in certain
proportional fonts. They are simply not available in any monospace fonts, so
it's impossible for me to do what I need to do without them.

Even if those characters were available in a monospace font, I just prefer the
look of some of these proportional fonts, so would prefer to use them for
purely aesthetic reasons as well.

This is not for coding purposes, for which I do prefer monospace fonts, for
alignment reasons. But if it was possible to get monospace-like alignment with
proportional fonts, and a clear distinction between the characters 0O1l;:,.`',
then I might prefer them for coding as well, since there seem to be a much
greater choice of proportional fonts than monospace fonts.

On the other hand, I'm pretty happy with using Inconsolata for programming, so
I'm not sure I'd switch. But it'd be nice to have the choice.

~~~
ur-whale
From a comment I made below:

How much would you like to read non-monospace code with an array of colors
encoded in hexadecimal ?

~~~
captainmuon
In many proportional fonts, numbers and certain punctuation, like "#", have
the same width. In others, you can explicitly select "table figures" to get
this effect.

------
cup-of-tea
One way is to use emacs and use evil-mode for vi behaviour.

I use proportional fonts for a few things in emacs. It's really nice.

~~~
chungy
It sounds counter-intuitive to use another editor, especially Emacs, but this
might actually be the best advice. Emacs is on top of the game for
proportional text editing, as well as the ability to make it behave very much
(even exactly so) like Vim.

I'd recommend watching this talk for why:
[https://www.youtube.com/watch?v=JWD1Fpdd4Pc](https://www.youtube.com/watch?v=JWD1Fpdd4Pc)

------
sunstone
I hope not.

~~~
namnemul
Why not? There are enough people that use Vim to just write prose. You don’t
need monospaced fonts then.

~~~
mseepgood
I also program in non-monospaced fonts. There is no reason not to.

~~~
stinos
No reason at all? Not saying you're wrong per se, but basically you're saying
all the monospaced fonts out there used by default in a ton of code editors
are there for _no reason_. Or at least not a good one. Can you elaborate?

~~~
Stratoscope
Many programmers believe that it is impossible, or at least impractical, to
code effectively in a monospaced font.

For most kinds of code, this is a mistaken belief.

You only need a monospaced font if you want to use column alignment. But it's
really quite rare that column alignment is necessary. It can almost always be
replaced with simple indentation.

Here's what I mean by column alignment:

    
    
      function foo(firstArgument,
                   secondArgumentFunctionCall(itsArgument,
                                              itsOtherArgument),
                   thirdArgument) {
          bar();
      }
    

Obviously, those arguments won't line up in a proportional font. But this kind
of column alignment is a bad practice anyway. It leads to excessive line
lengths, spurious VCS diffs, and is just generally fiddly.

The Rust/Servo coding guidelines formerly mandated column alignment like this.
But after seeing the problems it caused in their codebase, they switched to a
pure indentation style like the one I've used for many years.

The idea is simple. Stop making a distinction between statements and
expressions, and instead format expressions just as you would format blocks of
statements:

    
    
      function foo(
          firstArgument,
          secondArgumentFunctionCall(
              itsArgument,
              itsOtherArgument
          ),
          thirdArgument
      ) {
          bar();
      }
    

Once you start using this kind of format, it no longer matters whether you use
a monospaced or proportional font. It doesn't even matter whether you use tabs
or spaces! The notion of "tabs for indentation, spaces for alignment" goes
away when you don't use alignment.

I think every programmer should try using proportional fonts for a while. Even
if you decide you prefer monospaced after all, it's an educational experience
to see that monospaced fonts are just not necessary for most programming, and
that tabs work fine once you stop using alignment.

~~~
geezerjay
> Many programmers believe that it is impossible, or at least impractical, to
> code effectively in a monospaced font.

Your post was the very first place I've ever saw that assertion in any shape
or form. I never heard anyone come close to make that assertion ever.

Moreover, modern IDEs started featuring functionalities that rely on monospace
fonts, such as selecting blocks of text by both rows and columns.

You should pass off your personal opinion as your own personal opinion instead
of posting baseless assertions wrapped in an unbelievable appeal to
popularity.

~~~
Stratoscope
I'm sorry, I meant to get back to you a week ago.

As pmoriarty pointed out, that was indeed a typo, and a rather embarrassing
one!

The funny thing was that as I was writing that sentence, I first wrote:

"The vast majority of programmers believe..."

And then I decided to tone down the language a bit. But my initial wording
would have made the typo fairly obvious. So it goes. :-)

> functionalities that rely on monospace fonts, such as selecting blocks of
> text by both rows and columns.

I use that "column selection" mode with proportional fonts too. It works fine,
even though the selected block has ragged right edges.

