situation 1: in CentOS or Debian and other Unix systems, when using VIM to edit the file, input Chinese, Chinese garbled:
#vim/ROOT/.VIMRC
Enter the following configuration:
Syntax on
set fileencodings=ucs-bom,utf-8,utf-16,gbk,big5,gb18030,latin1
set Fileencoding=utf-8
: Wq
Vim again when editing OK.
Explanation: Syntax on represents syntax highlighting, fileencoding represents the default file encoding when saving files, and Fileencodings indicates that Vim reads files using a sequence of coded identifiers that match from left to right.
Case 2: Files written on Windows, uploaded to Linux, vim edit garbled. The reason is that Windows uses GBK encoding by default, and on Linux, use the ICONV command to turn code:
#iconv-F gbk-t UTF-8 Test.txt-o test2.txt
Vim again when editing OK.
Case 3: in SecureCRT or Xshell ssh tools, vim editing files garbled. This is a good situation: Modify the client's encoding format. Take SecureCRT as an example: Find options---session options---terminal---appearance, charset encoding to utf-8 on the good.