Vim Chinese garbled how to solve

Source: Internet
Author: User

In general, it is only necessary to correctly set the coded identification sequence of vim and seldom encounter garbled problems:

set fileencodings=ucs-bom,utf-8,utf-16,gbk,big5,gb18030,latin1

This setting is sequential, and the general principle is to be as unique as possible and not to be confused with other encodings (for example, Ucs-bom, because the relationship with the BOM header is difficult and confusing), and can then be sorted in descending order of the usual degree. Latin1 as fallback in the last place.

This sequence may not be scientific or complete (both Japanese and Korean are not included), but at least in my current usage (English and some ASCII extensions/variants, simplified and traditional Chinese) have not experienced any problems. If a friend knows the better order, please reply or modify my answer directly.

If you encounter garbled characters after opening, you will need to manually specify the encoding. Note that the method of setting "fileencoding" (note without s) mentioned in many places on the network is wrong . Read the Help document carefully:
When
reading a file ' fileencoding ' is set from ' fileencodings '. To read a file in a certain encoding it won ' t work by setting ' fileencoding ', use the |++enc| Argument.

When you open a file, VIM has chosen the code and thought it is the code, set fileencoding just modify what you want the file to exist, equivalent to the encoding of the set save-- Once the different fileencoding has been set, the file becomes modified and needs to be saved (the code is changed).

The correct approach is to use the ++enc parameter when opening a file:
:e ++enc=someencoding somefile

If you want to reopen the current file, omit the filename somefile. Here's a wiki you can look at: reloading a file using a different encoding

Finally, don't touch encoding this setting! This is the internal code of VIM, unless you're sure you know what you're doing, you don't usually need to change it.

Vim Chinese garbled how to solve

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.