Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert Unicode character U+2611 in gvim

Tags:

vim

unicode

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!!!

like image 628
wangkaibule Avatar asked Mar 08 '15 10:03

wangkaibule


People also ask

How do I insert a Unicode character?

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.

How do I type Unicode Orcode?

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.

How do I insert a Unicode character in Linux?

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 .


1 Answers

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).

like image 130
Ingo Karkat Avatar answered Oct 24 '22 13:10

Ingo Karkat