Insert special • characters ◆

4.8
(88)

A while back, we wrote about how to insert non-printable and other special characters with <ctrl-v> in insert mode. But Vim has another way called digraphs. (See :help digraph). While in insert mode, you can insert special characters in Vim by pressing <ctrl-k> followed by a two-character lookup code. For example, <ctrl-k> ?2 will insert the approximately equal symbol: .

When would you use this? Note-taking for one. Write any kind of prose in Vim and you are sure to come across a use for a character that’s not on your keyboard: Currency symbols, dashes, bullets, and much more. Here are some you may find helpful. Notice how each two-letter combination (“di-graph”) is designed to be memorable. Certainly much easier than remembering numeric codes.

  • oo • (bullet)
  • Db ◆ (diamond bullet)
  • '% ϴ (Greek theta)
  • Pd £ (British pound symbols)
  • Co © (copyright symbol)
  • Rg ® (registered trademark symbol)
  • Eu € (euro symbol)
  • -1 ‐ (hyphen)
  • -N – (en dash)
  • -M — (em dash)

Vim provides a list of all digraphs available on your system (compilation options can affect the list) just by using the :dig command. In the screencast below, I show this mapping list and then insert a few characters with <ctrl-k>.

I’d love to know what other people use this for and which characters are the ones they reach for often. Email me or share a comment on the post.

How useful was this tip?

Average rating 4.8 / 5. Vote count: 88

No votes so far! Be the first to rate this tip.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Written by

Colin Bartlett

105 Posts

Vim enthusiast and software developer for more than 20 years.
View all posts