17

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?

1
  • 1
    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? Jun 4, 2014 at 15:08

1 Answer 1

25
+50

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.

3
  • 1
    This also solved the issue of not being able to input Chinese characters for me. Oct 22, 2016 at 17:42
  • Could someone expand on what C-R ="\xe2\x82\xa9" <enter> does? Feb 14, 2020 at 17:27
  • @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. Feb 14, 2020 at 18:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .