₩
is the currency symbol for North Korea. Its Unicode code-point is U+20a9
.
In insert mode, I can press Ctrl-V u20a9
to type it.
If I only know its UTF-8 form e2 82 a9
, how can I type it easily?
UTF-8 is an encoding system for Unicode. It can translate any Unicode character to a matching unique binary string, and can also translate the binary string back to a Unicode character. This is the meaning of “UTF”, or “Unicode Transformation Format.”
Inserting Unicode characters To insert a Unicode character, type the character code, press ALT, and then press X. For example, to type a dollar symbol ($), type 0024, press ALT, and then press X. For more Unicode character codes, see Unicode character code charts by script.
Tip of the Trade: The editor Vim supports unicode natively. There are three ways to take advantage of unicode's capabilities via Vim. The one that's best for you will depend on your setup and needs. character codes are available online.
I just found this solution:
In insert mode, press Ctrl-R ="\xe2\x82\xa9"
Enter.
I'd like to know about any other (shorter?) methods, though.
Same solution with a twist of automation to help remember it:
command! -nargs=* UTF8 call EncodeUTF8(<f-args>)
fun! EncodeUTF8(...)
let utf8str = ""
for i in a:000
let utf8str .= "\\x" . i
endfor
exe "norm i" . eval("\"".utf8str."\"")
endfun
Now you can :UTF8 e2 82 a9
You can also type this particular character with <C-k>W=
. See :help digraph-table-mbyte
.
Note that you can also get information about a character with ga
and g8
in normal mode. So it might be easier to just do <C-r>="\xe2\x82\xa9"
once and then do ga
to get the code-point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With