I work on webpages involving Non-English scripts from time to time, most of them uses utf-8 charset, VIM and Gvim does not display UTF-8 Characters correctly.
Using VIM 7.3.46 on windows 7 64 bit, with set guifont=Monaco:h10
in _vimrc
Is there a way to fix this?
Update: I've googled around and found set guifontwide
acts as second fallback for regional languages.
I added the following lines in _vimrc and most of my problems got solved.
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 for Chinese, The problem is I don't know how they got the font name to work with VIM, Courier New
is mentioned as Courier_New
also NSimsun
is nowhere in the font directory. The font I want to use is Latha
But, I don't know how to use it in _vimrc File. set guifontwide=latha:h12
or set guifontwide=Latha:h12
doesn't work.
If I successfully set the guifontwide
to latha
, then my problem will be solved, How to do it?
This question is related to
vim
On Windows gvim just select "Lucida Console" font.
I couldn't get any other fonts I installed to show up in my Windows GVim editor, so I just switched to Lucida Console
which has at least somewhat better UTF-8 support. 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.
On Microsoft Windows, gvim wouldn't allow you to select non-monospaced fonts. Unfortunately Latha is a non-monospaced font.
There is a hack way to make it happen: Using FontForge (you can download Windows binary from http://www.geocities.jp/meir000/fontforge/) to edit the Latha.ttf and mark it as a monospaced font. Doing like this:
Good luck!
Is this problem solved meanwhile?
I had the problem that gvim didn't display all unicode characters (but only a subset, including the umlauts and accented characters), while :set guifont?
was empty; see my question. After reading here, setting the guifont
to a sensible value fixed it for me. However, I don't need characters beyond 2 bytes.
In Linux, Open the VIM configuration file
$ sudo -H gedit /etc/vim/vimrc
Added following lines:
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
Save and exit, and terminal command:
$ source /etc/vim/vimrc
At this time VIM will correctly display Chinese.
this work for me and do not need change any config file
vim --cmd "set encoding=utf8" --cmd "set fileencoding=utf8" fileToOpen
If Japanese people come here, please add the following lines to your ~/.vimrc
set encoding=utf-8
set fileencodings=iso-2022-jp,euc-jp,sjis,utf-8
set fileformats=unix,dos,mac
Did you try
:set encoding=utf-8
:set fileencoding=utf-8
?
Try to reload the document using:
:e! ++enc=utf8
If that works you should maybe change the fileencodings
settings in your .vimrc.
Source: Stackoverflow.com