2

I would like a quick and easy way to insert certain unicode characters into text files with vim that I use often, for example, the British Pound Sterling and the tick characters instead of typing:

i C-v u00A3 = £
i C-v u2713 = ✓
Tony Barganski
  • 1,873
  • 20
  • 17

2 Answers2

3

TL;DR

After some digging around, I was able to come up with these:

Digraph Shortlist

Insert Digraphs
i C-k OK = ✓
i C-k $$ = £
i C-k Eu = €
i C-k XX = ✗
i C-k TM = ™
i C-k Co = ©
i C-k Rg = ®
i C-k /- = †
i C-k RT = √
i C-k *1 = ☆
i C-k *2 = ★

NB: tmux maps C-k so unmap it for vim in tmux.conf

This new functionality was added to Vim 8.2 released in May 2019.

These are entered from insert mode using C-k <2letter shortcut>

Type :digraph or just :dig to display a list of all possible digraphs in Vim.


P.S.

Not to be confused with diacritics which are character accents like the German umlaut ü.

Hope this helps someone out there too.

Tony Barganski
  • 1,873
  • 20
  • 17
0

I believe the quickest and simplest way to insert the Unicode code is to add abbreviations for the characters you use most often:

:iabbrev upound u00A3
:iabbrev utick u2713

These commands adds abbreviations and makes them available in insert mode. To expand them, write the name ("upound" or "utick") followed by a non-keyword character such as comma, space, Esc, or Enter.

runar
  • 2,667
  • 2
  • 15
  • 23
  • It seems to me like this just types "u00A3" or "u2713" instead of inserting their corresponding unicode characters... – lindhe Oct 14 '22 at 14:05