9

What settings do I need to set in Vim/gVim to be able to view Unicode text files which have text in many languages?

You may make these assumptions:

  • The number of languages is more than two.
  • Some of the languages are Chinese, Japanese, and Korean.
  • It is enough if I can view these files in gVim (not necessarily Vim).
  • gVim 7.0 running on Windows.

Here is a text sample, which when saved in Unicode opens fine in Notepad, but shows up as gibberish in gVim:

This is English.
这是中文。
これは日本です。
한국입니다.
ಇದು ಕನ್ನಡ.
2
  • Jerryjvl: There seems to be Unicode support in GViM. I have not been successful in enabling it to work with >2 languages. vim.org/htmldoc/mbyte.html Jul 22 '09 at 3:20
  • 3
    Your example works just fine when pasted into gvim on Linux. Suggest upgrading OS :-D
    – derobert
    Jul 22 '09 at 4:38
7

Using gVim on Windows, I did the following two things:

:set encoding=utf-8
:set guifont=*

The second command brings up a font picker. By choosing the font "@MS Mincho", I got some of the Japanese characters to display, but oddly they were rotated 90 degrees to the left.

Anyway, you'll have to set the encoding before loading or pasting text into gVim (otherwise it might just convert them to all question marks). Then you'll have to find a font that is (a) fixed width, and (b) includes the characters you want to see. I don't seem to have such a font on my system at the moment, but you may.

2
  • the same is true for any os: you need vim to use the right encoding AND the right font to display the glyphs of the font. so, mark greg's answer 'accepted' :)
    – akira
    Sep 22 '09 at 5:13
  • Thanks Greg! So by setting the encoding as UTF-8 we enable GViM to make sense of the bytes it is reading, but sadly it cannot display all those languages using a single fixed-width font, hence gibberish is displayed. Dec 5 '09 at 7:23
0

Using the following settings in your .vimrc
:set encoding=utf-8
:set guifont=*
:set guifontwide=*

may work for you. It worked for me for chinese/japanese characters.

1
  • You can also try the following: :set fileencoding=utf-8 :set fileencodings=ucs-bom,utf-8,latin1 :set *encoding=utf-8
    – GuruM
    Aug 7 '12 at 11:05
0

The font Arial Unicode MS supports japanese, chinese and korean as well as vietnamese and arabic. You could try using that font, though I don't believe it is monospaced.

http://www.microsoft.com/typography/fonts/font.aspx?FMID=1081

There may be other pan-language fonts out there, perhaps monospaced ones as well, but I don't know of them.

edit

I found this page with a few fonts that support all three languages. Some of them are available as free downloads: http://www.wazu.jp/gallery/Fonts_Japanese.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.