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

How do I see the raw UTF-8 byte values of the character under the cursor?

Answer

g8

Explanation

Pressing g8 in normal mode displays the UTF-8 encoding of the character under the cursor as a sequence of hex bytes. This is distinct from ga (which shows decimal, hex, and octal for a codepoint) — g8 gives you the actual multi-byte storage representation, which is essential when debugging encoding issues, writing byte-level processing scripts, or inspecting non-ASCII characters.

How it works

  • g is a prefix for a family of extended commands
  • 8 after g tells Vim to show the 8-bit UTF-8 byte sequence
  • The output appears in the message area at the bottom, e.g. <c3><a9> for é
  • For ASCII characters (U+0000 – U+007F), the byte sequence is a single hex value

Example

With the cursor on é (U+00E9, LATIN SMALL LETTER E WITH ACUTE):

g8

Output in the message area:

<c3> <a9>

These are the two bytes 0xC3 0xA9 — the UTF-8 encoding of U+00E9.

For a CJK character like (U+4E2D), g8 shows:

<e4> <b8> <ad>

Tips

  • Compare with ga: shows the Unicode codepoint and code in decimal/hex/octal, not the storage bytes
  • Useful when a file appears corrupted: g8 reveals unexpected byte sequences like <ef> <bb> <bf> (a UTF-8 BOM)
  • Works in any buffer, including help files and terminal buffers

Next

How do I delete all lines matching my last search pattern without retyping it?