How to view UTF-8 characters in VIM or Gvim

I work on web pages that use non-English scripts from time to time, most of them use utf-8 encoding, VIM and Gvim do not display UTF-8 characters correctly.

Using VIM 7.3.46 for Windows 7 64 bit, with set guifont=Monaco:h10 in _vimrc

Is there any way to fix this?

Update: I googled around and found that set guifontwide acts as a second reserve for regional languages.

I added the following lines to _vimrc, and most of my problems were resolved.

 set enc=utf-8 set fileencoding=utf-8 set fileencodings=ucs-bom,utf8,prc set guifont=Monaco:h11 set guifontwide=NSimsun:h12 

The above NSimsun font works in Chinese. The problem is that I don’t know how they got the name of the font for working with VIM, Courier New is also referred to as Courier_New and NSimsun nowhere in the font directory. The font I want to use is Latha But I do not know how to use it in the _vimrc file. set guifontwide=latha:h12 or set guifontwide=latha:h12 does not work.

If I successfully installed guifontwide in Latha , then my problem will be solved, how to do it?

+82
vim
Mar 02 '11 at 11:11
source share
6 answers

Try reloading the document using:

 :e! ++enc=utf8 

If this works, you can change the fileencodings settings in your .vimrc.

+50
Mar 03 '11 at 15:51
source share

You tried

 :set encoding=utf-8 :set fileencoding=utf-8 

?

+34
Mar 02 '11 at 12:16
source share

On M $ Windows, gvim will not let you choose non-font-size fonts. Unfortunately, Latha is a non-width font.

There is a way to hack: Using FontForge (you can download the Windows binary from http://www.geocities.jp/meir000/fontforge/ ) to edit Latha.ttf and mark it as a monospace font. Doing the following:

  • Download fontforge, select latha.ttf.
  • Menu: Element β†’ Font Information
  • Select "OS / 2" from the left list in the "Font Information" dialog box.
  • Select the Panosa tab
  • Set Proportion = Monospaced
  • Save the new TTF version of this font, try it!

Good luck

+4
Mar 24 '11 at 10:55
source share

Is this problem resolved in the meantime?

I had a problem that gvim did not display all Unicode characters (but only a subset, including umlauts and accented characters), whereas :set guifont? was empty; see my question . After reading here, setting guifont to a reasonable value, fixed this for me. However, I do not need characters beyond 2 bytes.

+1
Mar 26 '14 at 18:22
source share

I was unable to get any other fonts that I installed to display in my Windows GVim editor, so I just switched to Lucida Console , which has at least slightly better support for UTF-8. Add this to the end of your _vimrc :

 " For making everything utf-8 set enc=utf-8 set guifont=Lucida_Console:h9:cANSI set guifontwide=Lucida_Console:h12 

Now I see at least some UTF-8 characters.

+1
Nov 07 '17 at 16:39
source share

If Japanese people come here, add the following lines to ~/.vimrc

 set encoding=utf-8 set fileencodings=iso-2022-jp,euc-jp,sjis,utf-8 set fileformats=unix,dos,mac 
0
Dec 19 '17 at 1:23
source share



All Articles