How do I insert special characters like arrows, math symbols, or accented letters in Vim?
Answer
<C-k>
Explanation
Vim has a built-in digraph system that lets you type special characters using short two-character codes. Instead of hunting for Unicode code points or copy-pasting from external sources, you can press <C-k> in insert mode followed by a two-character sequence to produce the character directly.
How it works
<C-k>{char1}{char2}— in insert mode, press Ctrl-K then type two characters that represent the digraph- Vim inserts the corresponding Unicode character at the cursor
- Use
:digraphsto see the full list of available digraph codes
Example
Some commonly useful digraphs:
<C-k>-> → (right arrow)
<C-k><= ≤ (less than or equal)
<C-k>>= ≥ (greater than or equal)
<C-k>!= ≠ (not equal)
<C-k>OK ✓ (checkmark)
<C-k>XX ✗ (ballot X)
<C-k>Eu € (Euro sign)
<C-k>Co © (copyright)
<C-k>e' é (e acute)
<C-k>PI π (pi)
Typing in insert mode:
Before: The cost is EUR
Type: <C-k>Eu
After: The cost is € EUR
Tips
- Run
:digraphsto browse all available codes — the output shows the two-char code, the resulting character, and its decimal value - You can define custom digraphs with
:digraph {char1}{char2} {decimal}— for example,:digraph hh 9829mapshhto ♥ - If you know the exact Unicode code point, use
<C-v>u{hex}instead — for example,<C-v>u2192for →