How to view UTF-8 Unicode characters in VIM

43,791

If your current locale is in an utf-8 encoding, Vim will automatically start in utf-8 mode.

If you are using another locale, set below in your user ~/.vimrc file:

set encoding=utf-8

You might also want to select the font used for the menus. Unfortunately this doesn't always work.

Also you have this option to force encoding with :set fileencodings=utf-8. You can find the documentation here

another solution is: In insert mode, press Ctrl-R ="\xe2\x82\xa9" Enter in order to directly input UTF-8 characters using thier Hex Encoding.

the \xe2\x82\xa9 is Hex Encoding of (the currency symbol for North Korea) character.

ref: Vim documentation

Note: If you did the above configuration but still you were not able to see Unicode characters well or type, check in your Terminal or Console configuration if Character encoding was set to UTF-8.

Read also Special characters in Vim.

Share:
43,791

Related videos on Youtube

Vivek Pradhan
Author by

Vivek Pradhan

Hey there, I work for a business advisory consulting firm and code mostly as a hobby. Lately, I have been deeply enthralled by javascript and like to read up and learn it whenever. I am also particularly interested in home automation and the whole Internet of things landscape leveraging open source technologies. Github Hobbies - Like to cube and watch cat videos on youtube.

Updated on September 18, 2022

Comments

  • Vivek Pradhan
    Vivek Pradhan about 1 year

    I am using VIM 7.4 on an Ubuntu 14.04 64 bit machine. In my .vimrc file, I have the following lines:

    " Use UTF-8 without BOM
    set encoding=utf-8 nobomb
    

    The config file basically uses Unicode character to display white spaces like tabs, new lines, etc. The complete .vimrc file is taken from Paul Irish's dotfiles.

    On an earlier install of 14.04 as well as in previous distributions, I was able to see the unicode characters without any problems but not with this one.

    I also tried:

     set fileencodngs=utf-8
    

    But, the above setting has no effect and I still see garbled characters on the screen. Is there any way around this?

    • Michael Miller
      Michael Miller over 9 years
      Can you give a link to an example file that looks garbled to you? And can you include a screenshot of what you are seeing in vim? What is the value of the fenc variable after opening a file?
  • Zelphir Kaltstahl
    Zelphir Kaltstahl about 7 years
    This also solved the issue of not being able to input Chinese characters for me.
  • user1717828
    user1717828 over 3 years
    Could someone expand on what C-R ="\xe2\x82\xa9" <enter> does?
  • αғsнιη
    αғsнιη over 3 years
    @ussr1717828 that's the UTF-8 encoding form of (the currency symbol for North Korea) and that allow user directly to type literal by using its UTF-8 Hex coding with Ctrl+R="..." - Enter.