In my previous article Ligature Fonts for Terminal, VS Code, Neovim and Emacs, I showed you how to configure fonts with ligatures. In this article I will show you how to configure Vim/Neovim to use Unicode characters to display programming symbols.
In Vim/Neovim, digraphs are used to enter characters that normally cannot be entered by an ordinary keyboard. These are mostly printable non-ASCII characters. The digraphs are easier to remember than the decimal number that can be entered with
:digraphs and you can see a list of defined digraphs.
E.g. to enter the copyright symbol, in insert mode, type
Control-K, and then
Co (capital C and lower case o).
Similarly for Emacs, if you installed emacs-evil then digraph feature is available to you.
Code Fonts using Digraphs and Conceal
Vim/Neovim associates each file you opened to a particular syntax. E.g. open up a Python file, and type
:set syntax? and you can see
syntax=Python. (Note: make sure you have
syntax enable in your .
:verbose set ft? and you can see the file type and location of filetype.vim which tells you the list of supported file types.
Vim is extremely flexible and allow us to define colors, compilers, key mappings and many others. In this case I can also define my own syntax file. Type
:h mysyntaxfile-add and it tells you how to create custom syntax file in
after/syntax folder from
Combining this with the
conceal feature now I can use Vimscript to display programming symbols in Unicode characters.
Below is an example for Rust. I create a file called
rust.vim in the
And now if I open a Rust file, I can see the Unicode characters are displayed based on the syntax file I defined.
Using this method you can easily apply it to any languages. Here is another example for Python.
Do also check out the following articles
Vim — Improve Your Speed
Vim provides many ways of moving around documents as well as jumping between buffers. In this article we are going to…