when I try to enter this Unicode character :☑(U+2611) in vim using the command like : ^Vu2611
(which means press ctrl+V then type u2611 in insert mode),Vim somehow breaks it into two characters : &
(26) and ^Q
(11).
There's no any problem when I tried to insert other kind of characters like □ (U+a1f5).
It seems like Vim stopped its parsing immediately after 26
(which represents character '&') has been read .
So,how can I insert this kind of Unicode characters in Vim (I have tried to paste it into Vim ,it doesn't work)? Please Help!!!
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.
This is an extension for Visual Studio Code which adds commands for inserting Unicode characters/codes and Emoji. The commands can be executed via the command palette ( View > Command Palette... / Ctrl + Shift + P ) or bound to keyboard shortcuts. No keys are bound by default.
In X11 (Linux and other Unix variants including ChromeOS) In many applications one or both of the following methods work to directly input Unicode characters: Holding Ctrl + ⇧ Shift and typing u followed by the hex digits, then releasing Ctrl + ⇧ Shift .
In order to process Unicode characters, Vim must use an 'encoding'
that is able to represent those characters. With a value of latin1
, the mentioned character cannot be encoded (this 8-bit encoding only includes ASCII and several Western European characters, see here).
So, you need to
:set encoding=utf-8
With that, any newly created file will use that encoding, and you should be able to insert Unicode characters and write them (also with another Unicode file encoding, like :w ++enc=ucs-2le
; but if you tried to persist as :w ++enc=latin1
, you'd get a CONVERSION ERROR
).
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