Vim encoding settings (for conversion)

Source: Internet
Author: User

 

The encoding in VIM is mainly related to three parameters: ENC (encoding), fenc (fileencoding), and fence (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 save the file as a different code. For example, I: Set fenc = UTF-8, And then: W, the file is saved as UTF-8,: Set fenc = gb18030, And then: W, 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

Only file encoding can be guessed.

The function of ENC is to show that, no matter what encoding the final file is, VIM converts 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_ch.gb18030 or zh_CH.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 can not display Chinese, and finally configure ENC for UTF-8 to display.

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

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