vim 中文乱码问题

vim 有一下三种编码

1、fileencoding 在vim中e ++enc=cp936设置,cp936是中文gbk还是gb2312, vim按此格式载入文件,按此格式保存文件
2、encoding  LOCALE环境变量值获取,是vim buffer中的格式,是vim内部核心格式,载入时用iconv 从fileencoding到此格式encoding转换,保存时此格式encoding转成fileencoding
3、termencoding 在vim中set termencoding=cp936设置, vim输出给终端的格式

 

在xshell,secureCRT等终端工具中不管文件是gbk(兼容gb2312)还是utf8,终端工具的编码统一设置成utf8,utf8能表示任何字符。然后在vim中根据文件的编码设置fileencoding就行了。设置不能仅仅用set fileencoding=gbk,设置了还得重新载入文件才行,载入的同时设置fileencoding,就是":e ++enc=gbk"

你可能感兴趣的:(工具)