Skip to content
Jean Guyomarc'h edited this page Jun 13, 2020 · 3 revisions

If you use an OpenType font that provides support for ligatures, such as Fira Code, you can benefit from automatic ligatures substitution. See Changing the Font for instructions on how to customize the font.

The idea is that the OpenType font automatically use a single glyph to represent adjacent characters that are nice together. For example <= may be replaced with . This replacement glyph shall span on the same amount of columns that the original characters.

Eovim adds a nice addition to this feature: when you place the cursor on a glyph that was substituted, it forces the font engine to render the original characters are independent glyphs, so you can clearly see what you are editing.

Demo

The GIF below illustrates how Eovim handles this. Everything that happens here is automatic, there are no user input (except of course that the text being typed) to trigger ligatures substitution. Ligatures are replaced as you type. This is actually the font engine that does all the work. However, when you place the cursor on a substituted glyph, Eovim forces the font engine to display the original characters under the cursor. This allows the developer to clearly visualize what is currently being editing.

How do I make this work?

It is the font that does the work. So to have ligatures support, your font needs to provide the feature. You can't take a random font (e.g. Courier) and expect characters to be substituted. For instance, install Fira Code, make it effective, and this should work out of the box.

Can ligatures be turned off?

No, because this is built-in in the font. If you don't like ligatures substitution, you have use a font that does not provide this feature.

Can the cursor stop cutting ligatures?

By default, when the cursor is above a ligature glyph, Eovim automatically inserts two unicode invisible separators in the text rendering area, which effectively breaks the ligature. Of course, these are never inserted in the document! This behavior can be turned off by setting g:eovim_cursor_cuts_ligatures to zero and re-starting eovim:

let g:eovim_cursor_cuts_ligatures = 0