You can use %b
or %B
in statusline
or rulerformat
. From :help statusline
:
b N Value of character under cursor.
B N As above, in hexadecimal.
For example:
set statusline=%b\ 0x%B
Gives you:
8984 0x2318
Another way is to use ga
or the :ascii
command. From :help ga
:
:as[cii] or ga :as :ascii
ga Print the ascii value of the character under the
cursor in decimal, hexadecimal and octal.
Which will give you:
<⌘> 8984, Hex 2318, Octal 21430
Another useful mapping is g8
:
e2 8c 98
Which prints the hex value of the actual bytes stored in the file (this command assumes UTF-8).
In addition there are some plugins you could use:
unicode.vim adds various useful unicode-related commands. Use :UnicodeName
to get details of the character under the cursor.
characterize.vim; this expands the ga
command with the unicode name, similar to unicode.vim.
My own uni CLI tool has a little Vim integration script which provides :UnicodeName
from unicode.vim (but none of the other features).