Linux under the terminal, vim display Chinese as garbled

Source: Internet
Author: User

This problem, mainly or some environment variables are not caused by setting.


The main modified documents include:

1./var/lib/locales/supported.d/local

2./etc/environment

3.~/.vimrc


First of all

sudo vim/var/lib/locales/supported.d/local
En_hk. UTF-8 UTF-8 en_US. UTF-8 UTF-8 ZH_CN. UTF-8 UTF-8 ZH_CN. GBK GBK #增加 zh_cn. GB2312 GB2312 #增加 zh_cn. GB18030 GB18030 #增加
sudo dpkg-reconfigure locales


Then, edit the/etc/environment

sudo vim/etc/environment 1 path= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" 2 Language= "Zh_CN:zh:en_US:en" 3 lang= "ZH_CN. UTF-8 "4 lc_numeric=" ZH_CN. UTF-8 "5 lc_time=" ZH_CN. UTF-8 "6 lc_monetary=" ZH_CN. UTF-8 "7 lc_paper=" ZH_CN. UTF-8 "8 lc_identification=" ZH_CN. UTF-8 "9 lc_name=" ZH_CN. UTF-8 "Ten lc_address=" ZH_CN. UTF-8 "Lc_telephone=" ZH_CN. UTF-8 "Lc_measurement=" ZH_CN. UTF-8 "Lc_ctype=" ZH_CN. UTF-8 "


Actually the main thing is to check language,lang,lc_* these are not correct. If the default open configuration file is missing something, add it to it. I've had less lc_ctype this one. These configurations are the specific configuration of the system locale, and as far as they are specific, Google can do it yourself.


Finally, edit the. vimrc file under the owner's directory

sudo vim ~/.VIMRC

Increase:

Set Fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936set Termencoding=utf-8set encoding=utf-8


Encoding: about the internal use of VIM code, will affect the internal vim buffer, message text and so on.

Termencoding: It's about using VIM in a terminal environment to tell vim what encoding to use.

Fileencodings:vim, when opening a file, guesses the encoding used by the file based on its configuration. When Vim saves the file, vim encodes the file according to fileencoding, Fileencodings can set multiple, and if fileencoding is not configured, vim encodes the file according to the fileencondings.


Finally, re-login, open the terminal, vim, the previous Chinese can be displayed correctly.



Linux under the terminal, vim display Chinese as garbled

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.