How to view UTF-8 Characters in VIM or Gvim

前端 未结 9 1105
天命终不由人
天命终不由人 2020-12-12 11:01

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

相关标签:
9条回答
  • 2020-12-12 11:22

    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.

    0 讨论(0)
  • 2020-12-12 11:27

    On Windows gvim just select "Lucida Console" font.

    0 讨论(0)
  • 2020-12-12 11:31

    Did you try

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

    ?

    0 讨论(0)
  • 2020-12-12 11:34

    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:

    1. Load fontforge, select latha.ttf.
    2. Menu: Element -> Font Info
    3. Select "OS/2" from left-hand list on Font Info dialog
    4. Select "Panose" tab
    5. Set Proportion = Monospaced
    6. Save new TTF version of this font, try it out!

    Good luck!

    0 讨论(0)
  • 2020-12-12 11:34

    this work for me and do not need change any config file

    vim --cmd "set encoding=utf8" --cmd "set fileencoding=utf8" fileToOpen

    0 讨论(0)
  • 2020-12-12 11:36

    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.

    0 讨论(0)
提交回复
热议问题