How do I insert a Unicode character by its code point in Vim?
Answer
<C-v>u{code}
Explanation
In insert mode, <C-v> followed by u and a 4-digit hex code inserts the Unicode character with that code point. For characters beyond the Basic Multilingual Plane, use U followed by an 8-digit hex code.
How it works
" In insert mode:
<C-v>u00e9 " Inserts é (e with acute accent)
<C-v>u2192 " Inserts → (right arrow)
<C-v>u2713 " Inserts ✓ (check mark)
<C-v>u03b1 " Inserts α (Greek alpha)
<C-v>U0001f600 " Inserts 😀 (grinning face, requires U for >4 hex digits)
Other insert methods with
<C-v>065 " Insert by decimal code (A = 65)
<C-v>o101 " Insert by octal code (A = 101 octal)
<C-v>x41 " Insert by 2-digit hex (A = 0x41)
<C-v>u0041 " Insert by 4-digit Unicode hex (A = U+0041)
<C-v>U00000041 " Insert by 8-digit Unicode hex
<C-v><Esc> " Insert a literal Escape character
<C-v><Tab> " Insert a literal Tab (even when expandtab is set)
Practical uses
- Insert special characters for documentation:
→,←,✓,✗,• - Insert math symbols:
α,β,∑,∞,≤,≥ - Insert currency symbols:
€(u20ac),£(u00a3),¥(u00a5) - Insert literal control characters for scripts and data files
Tips
- Use
gaon a character to see its code point (then use that code to insert it elsewhere) - Vim's digraph system (
<C-k>) is often faster for common accented characters <C-v>in insert mode is your escape hatch for inserting any literal character- Ensure your terminal and Vim use UTF-8 encoding:
:set encoding=utf-8 - Documented under
:help i_CTRL-V_digit