Vim encoding settings

Source: Internet
Author: User

The encoding in VIM is mainly related to three parameters: ENC (encoding), fenc (fileencoding), and fencs (fileencodings)

Fenc is the encoding of the current file, that is, a file that has been correctly displayed in VIM (the premise is that your system environment matches your ENC settings ), you can change fenc and then W to save the file into different encodings. For example, I: Set fenc = UTF-8 and then: W will save the file as UTF-8, And: Set fenc = gb18030 and then: W will save the file as gb18030. This value does not matter whether the file can be correctly decoded when it is opened.

Fencs is a list of guesses used to decode a file when it is opened. File encoding is not correct, so Vim can only guess the file encoding.

The function of ENC is to show that, no matter what encoding the final file is, VIM will convert it to the current system encoding for processing, so that it can be correctly displayed in the current system, therefore, ENC does this. In Windows, the default value of ENC is cp936, which is the default encoding of Chinese Windows. Therefore, ENC does not need to be changed. In Linux, as your system locale may be set to zh_cn.gb18030 or zh_CN.utf-8, your ENC should be set to gb18030 or UTF-8 (or GBK ). And I encountered the system locale is a en_US.UTF-8, do not set ENC explicit Chinese, and finally configure ENC for UTF-8 to explicit.

Finally, the Linux encoding is all UTF-8, VIM can display the Chinese vimrc file Configuration:

SetFileencodings = UTF-8, Gb2312, GBK, gb18030, big5
SetFenc = UTF-8
SetENC = UTF-8
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.