Wiki

by yszheda

View project onGitHub

Tip 17: Insert Unusual Characters by Character Code

Return to the top: <<Practical Vim>>

  • Vim can insert any character by its numeric code, and expects the numeric code to consist of three digits: <C-v>{code}

e.g. Insert "A" in insertion mode: <C-V>065

  • Insert a unicode character using its four-digit hexadecimal code: <C-v>u{code}

References:

# If you open the file in vim,
# then you can \"ayy@a the next line to execute the vim command: 
:h i_CTRL-V_digit
  • ga: show the numeric code for the character on the cursor

References:

# If you open the file in vim,
# then you can \"ayy@a the next line to execute the vim command: 
:h ga
Keystrokes Effect
<C-v>{123} Insert character by decimal code
<C-v>u{1234} Insert character by hexadecimal code
<C-v>{nondigit} Insert nondigit literally
<C-k>{char1}{char2} Insert character represented by {char1}{char2} digraph