vimtricks.wiki Concise Vim tricks, one at a time.

How do I insert a Unicode character by its codepoint in insert mode?

Answer

<C-v>u{hex}

Explanation

In insert mode, pressing <C-v> followed by u and a 4-digit hexadecimal codepoint inserts the corresponding Unicode character directly into the buffer. For code points above U+FFFF (supplementary planes), use <C-v>U with an 8-digit hex code instead.

How it works

  • <C-v>u{4hex} — insert Unicode character with a 4-digit hex codepoint (BMP)
  • <C-v>U{8hex} — insert Unicode character with an 8-digit hex codepoint (full range)
  • <C-v>{decimal} — insert character by decimal ASCII value (e.g., <C-v>65 inserts A)
  • <C-v>x{2hex} — insert character by 2-digit hex byte value

Example

To insert the em dash (U+2014):

Press: <C-v>u2014
Result: —

To insert the snowman emoji (U+2603):

Press: <C-v>u2603
Result: ☃

To insert the thumbs up emoji (U+1F44D, outside BMP):

Press: <C-v>U0001F44D
Result: 👍

Tips

  • Vim will accept the hex digits as you type and insert the character once you type enough digits or press a non-hex key
  • This works in any insert mode: regular insert (i/a), replace mode (R), and virtual replace mode (gR)
  • To look up a character's codepoint, use ga in normal mode to see the value under the cursor
  • Digraphs (<C-k>{char1}{char2}) are an alternative for common special characters and are often easier to remember

Next

How do I match a pattern only when it is preceded or followed by another pattern, without including that context in the match?