{"id":1483,"date":"2012-05-19T11:27:29","date_gmt":"2012-05-19T03:27:29","guid":{"rendered":"http:\/\/doophp.sinaapp.com\/?p=1483"},"modified":"2012-05-19T14:19:29","modified_gmt":"2012-05-19T06:19:29","slug":"vim-chinese-error","status":"publish","type":"post","link":"https:\/\/blog.vimge.com\/archives\/vim\/vim-chinese-error.html","title":{"rendered":"VIM\u4e2d\u6587\u4e71\u7801\u76f8\u5173\u914d\u7f6e\u9879\u8bf4\u660e"},"content":{"rendered":"

Win7\u5bf9\u7cfb\u7edf\u5185\u5b58\u7684\u8d2a\u5a6a\u7ec8\u4e8e\u8ba9\u6211\u4e0b\u5b9a\u51b3\u5fc3\u4f7f\u7528VIM\u4f5c\u4e3a\u5de5\u4f5c\u7f16\u8f91\u5668\u4ee3\u66ff\u4e86\uff0c2G\u5185\u5b58Win7\u4e0b\u5f00\u4e2aZendstudio\u6709\u65f6\u5019\u771f\u7684\u5f88\u8981\u547d.\u6211\u90a3\u53f0ThinkPad\u4e0a\u9762\u7684XP\u7cfb\u7edfVIM\u73af\u5883\u914d\u7f6e\u7684\u8fd8\u7b97\u987a\u624b\uff0c\u53ef\u60dc\u4e22\u5728\u6b66\u6c49\uff0c\u73b0\u4eba\u5728\u4e0a\u6d77\u6ca1\u529e\u6cd5\u53ea\u80fd\u91cd\u65b0\u4e00\u70b9\u70b9\u914d\u7f6e\u4e86.\u8bdd\u8bf4VIM\u5f3a\u5927\u800c\u7075\u6d3b\u7684\u914d\u7f6e\u529f\u80fd\uff0c\u521a\u5f00\u59cb\u4e5f\u662f\u4e00\u6b65\u4e00\u6b65\u914d\u7f6e\u51fa\u6765\u7684\uff0c\u771f\u7684\u8981\u518d\u91cd\u65b0\u914d\u7f6e\u4e00\u904d\u8fd8\u771f\u6709\u70b9\u4e00\u591c\u56de\u5230\u89e3\u653e\u524d\u7684\u72b6\u6001\uff0c\u4e0d\u8fc7\u8fd8\u597d\uff0c\u73b0\u5728\u4e0a\u624b\u5feb\u591a\u4e86.\u4eca\u5929\u7a0d\u5fae\u6574\u7406\u4e86\u4e00\u4e0bVIM\u4e2d\u6587\u4e71\u7801\u95ee\u9898\uff0c\u540e\u7eed\u6709\u65f6\u95f4\u51fa\u4e2a\u7ec8\u6781\u89e3\u51b3\u65b9\u6848\u5427\uff0c\u5c31\u8fd9\u70b9\u7834\u4e8b\uff0c\u8fd8\u7ecf\u5e38\u9047\u5230\uff0c\u7b80\u5355\u505a\u4e2a\u7b14\u8bb0.<\/p>\n

VIM\u4e2d\u4e0e\u4e2d\u6587\u4e71\u7801\u76f8\u5173\u7684\u914d\u7f6e\u9879\u5927\u6982\u53ef\u4ee5\u5206\u4e3a\u51e0\u4e2a\u90e8\u5206\uff1a\u7f16\u8f91\u5668\u3001\u83dc\u5355\u3001\u5de6\u952e\u83dc\u5355\u548c\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u6d89\u53ca\u5230\u7684\u914d\u7f6e\u9879\u6709\u4ee5\u4e0b\u51e0\u4e2a<\/p>\n

encoding<\/strong><\/p>\n

encoding \u662f Vim \u5185\u90e8\u4f7f\u7528\u7684\u5b57\u7b26\u7f16\u7801\u65b9\u5f0f\u3002\u5f53\u6211\u4eec\u8bbe\u7f6e\u4e86 encoding \u4e4b\u540e\uff0cVim \u5185\u90e8\u6240\u6709\u7684 buffer\u3001\u5bc4\u5b58\u5668\u3001\u811a\u672c\u4e2d\u7684\u5b57\u7b26\u4e32\u7b49\uff0c\u5168\u90fd\u4f7f\u7528\u8fd9\u4e2a\u7f16\u7801\u3002Vim \u5728\u5de5\u4f5c\u7684\u65f6\u5019\uff0c\u5982\u679c\u7f16\u7801\u65b9\u5f0f\u4e0e\u5b83\u7684\u5185\u90e8\u7f16\u7801\u4e0d\u4e00\u81f4\uff0c\u5b83\u4f1a\u5148\u628a\u7f16\u7801\u8f6c\u6362\u6210\u5185\u90e8\u7f16\u7801\u3002\u5982\u679c\u5de5\u4f5c\u7528\u7684\u7f16\u7801\u4e2d\u542b\u6709\u65e0\u6cd5\u8f6c\u6362\u4e3a\u5185\u90e8\u7f16\u7801\u7684\u5b57\u7b26\uff0c\u5728\u8fd9\u4e9b\u5b57\u7b26\u5c31\u4f1a\u4e22\u5931\u3002\u56e0\u6b64\uff0c\u5728\u9009\u62e9 Vim \u7684\u5185\u90e8\u7f16\u7801\u7684\u65f6\u5019\uff0c\u4e00\u5b9a\u8981\u4f7f\u7528\u4e00\u79cd\u8868\u73b0\u80fd\u529b\u8db3\u591f\u5f3a\u7684\u7f16\u7801\uff0c\u4ee5\u514d\u5f71\u54cd\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n

\u7531\u4e8e encoding \u9009\u9879\u6d89\u53ca\u5230 Vim \u4e2d\u6240\u6709\u5b57\u7b26\u7684\u5185\u90e8\u8868\u793a\uff0c\u56e0\u6b64\u53ea\u80fd\u5728 Vim \u542f\u52a8\u7684\u65f6\u5019\u8bbe\u7f6e\u4e00\u6b21\u3002\u5728 Vim \u5de5\u4f5c\u8fc7\u7a0b\u4e2d\u4fee\u6539 encoding \u4f1a\u9020\u6210\u975e\u5e38\u591a\u7684\u95ee\u9898\u3002\u5982\u679c\u6ca1\u6709\u7279\u522b\u7684\u7406\u7531\uff0c\u8bf7\u59cb\u7ec8\u5c06 encoding \u8bbe\u7f6e\u4e3a utf-8\u3002<\/p>\n

\u4e3a\u4e86\u907f\u514d\u5728\u975e UTF-8 \u7684\u7cfb\u7edf\u5982 Windows \u4e0b\uff0c\u83dc\u5355\u548c\u7cfb\u7edf\u63d0\u793a\u51fa\u73b0\u4e71\u7801\uff0c\u53ef\u540c\u65f6\u505a\u8fd9\u51e0\u9879\u8bbe\u7f6e\uff1a<\/p>\n

if has(“win32”)<\/p>\n

set fileencoding=chinese<\/p>\n

else<\/p>\n

set fileencoding=utf-8<\/p>\n

endif<\/p>\n

“\u89e3\u51b3\u83dc\u5355\u4e71\u7801<\/em><\/p>\n

set langmenu=zh_CN.utf-8<\/p>\n

source $VIMRUNTIME\/delmenu.vim<\/p>\n

source $VIMRUNTIME\/menu.vim<\/p>\n

“\u89e3\u51b3consle\u8f93\u51fa\u4e71\u7801<\/em><\/p>\n

language messages zh_CN.utf-8<\/p><\/blockquote>\n

termencoding<\/strong><\/p>\n

termencoding \u662f Vim \u7528\u4e8e\u5c4f\u5e55\u663e\u793a\u7684\u7f16\u7801\uff0c\u5728\u663e\u793a\u7684\u65f6\u5019\uff0cVim \u4f1a\u628a\u5185\u90e8\u7f16\u7801\u8f6c\u6362\u4e3a\u5c4f\u5e55\u7f16\u7801\uff0c\u518d\u7528\u4e8e\u8f93\u51fa\u3002\u5185\u90e8\u7f16\u7801\u4e2d\u542b\u6709\u65e0\u6cd5\u8f6c\u6362\u4e3a\u5c4f\u5e55\u7f16\u7801\u7684\u5b57\u7b26\u65f6\uff0c\u8be5\u5b57\u7b26\u4f1a\u53d8\u6210\u95ee\u53f7\uff0c\u4f46\u4e0d\u4f1a\u5f71\u54cd\u5bf9\u5b83\u7684\u7f16\u8f91\u64cd\u4f5c\u3002\u5982\u679c termencoding \u6ca1\u6709\u8bbe\u7f6e\uff0c\u5219\u76f4\u63a5\u4f7f\u7528 encoding \u4e0d\u8fdb\u884c\u8f6c\u6362\u3002<\/p>\n

\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5f53\u4f60\u5728 Windows \u4e0b\u901a\u8fc7 telnet \u767b\u5f55 Linux \u5de5\u4f5c\u7ad9\u65f6\uff0c\u7531\u4e8e Windows \u7684 telnet \u662f GBK \u7f16\u7801\u7684\uff0c\u800c Linux \u4e0b\u4f7f\u7528 UTF-8 \u7f16\u7801\uff0c\u4f60\u5728 telnet \u4e0b\u7684 Vim \u4e2d\u5c31\u4f1a\u4e71\u7801\u3002\u6b64\u65f6\u6709\u4e24\u79cd\u6d88\u9664\u4e71\u7801\u7684\u65b9\u5f0f\uff1a\u4e00\u662f\u628a Vim \u7684 encoding \u6539\u4e3a gbk\uff0c\u53e6\u4e00\u79cd\u65b9\u6cd5\u662f\u4fdd\u6301 encoding \u4e3a utf-8\uff0c\u628a termencoding \u6539\u4e3a gbk\uff0c\u8ba9 Vim \u5728\u663e\u793a\u7684\u65f6\u5019\u8f6c\u7801\u3002\u663e\u7136\uff0c\u4f7f\u7528\u524d\u4e00\u79cd\u65b9\u6cd5\u65f6\uff0c\u5982\u679c\u9047\u5230\u7f16\u8f91\u7684\u6587\u4ef6\u4e2d\u542b\u6709 GBK \u65e0\u6cd5\u8868\u793a\u7684\u5b57\u7b26\u65f6\uff0c\u8fd9\u4e9b\u5b57\u7b26\u5c31\u4f1a\u4e22\u5931\u3002\u4f46\u5982\u679c\u4f7f\u7528\u540e\u4e00\u79cd\u65b9\u6cd5\uff0c\u867d\u7136\u7531\u4e8e\u7ec8\u7aef\u6240\u9650\uff0c\u8fd9\u4e9b\u5b57\u7b26\u65e0\u6cd5\u663e\u793a\uff0c\u4f46\u5728\u7f16\u8f91\u8fc7\u7a0b\u4e2d\u8fd9\u4e9b\u5b57\u7b26\u662f\u4e0d\u4f1a\u4e22\u5931\u7684\u3002<\/p>\n

\u5bf9\u4e8e\u56fe\u5f62\u754c\u9762\u4e0b\u7684 GVim\uff0c\u5b83\u7684\u663e\u793a\u4e0d\u4f9d\u8d56 TERM\uff0c\u56e0\u6b64 termencoding \u5bf9\u4e8e\u5b83\u6ca1\u6709\u610f\u4e49\u3002\u5728 GTK2 \u4e0b\u7684 GVim \u4e2d\uff0ctermencoding \u6c38\u8fdc\u662f utf-8\uff0c\u5e76\u4e14\u4e0d\u80fd\u4fee\u6539\u3002\u800c Windows \u4e0b\u7684 GVim \u5219\u5ffd\u7565 termencoding \u7684\u5b58\u5728\u3002<\/p>\n

fileencoding<\/strong><\/p>\n

\u5f53 Vim \u4ece\u78c1\u76d8\u4e0a\u8bfb\u53d6\u6587\u4ef6\u7684\u65f6\u5019\uff0c\u4f1a\u5bf9\u6587\u4ef6\u7684\u7f16\u7801\u8fdb\u884c\u63a2\u6d4b\u3002\u5982\u679c\u6587\u4ef6\u7684\u7f16\u7801\u65b9\u5f0f\u548c Vim \u7684\u5185\u90e8\u7f16\u7801\u65b9\u5f0f\u4e0d\u540c\uff0cVim \u5c31\u4f1a\u5bf9\u7f16\u7801\u8fdb\u884c\u8f6c\u6362\u3002\u8f6c\u6362\u5b8c\u6bd5\u540e\uff0cVim \u4f1a\u5c06 fileencoding \u9009\u9879\u8bbe\u7f6e\u4e3a\u6587\u4ef6\u7684\u7f16\u7801\u3002\u5f53 Vim \u5b58\u76d8\u7684\u65f6\u5019\uff0c\u5982\u679c encoding \u548c fileencoding \u4e0d\u4e00\u6837\uff0cVim \u5c31\u4f1a\u8fdb\u884c\u7f16\u7801\u8f6c\u6362\u3002\u56e0\u6b64\uff0c\u901a\u8fc7\u6253\u5f00\u6587\u4ef6\u540e\u8bbe\u7f6e fileencoding\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u6587\u4ef6\u7531\u4e00\u79cd\u7f16\u7801\u8f6c\u6362\u4e3a\u53e6\u4e00\u79cd\u7f16\u7801\u3002\u4f46\u662f\uff0c\u7531\u524d\u9762\u7684\u4ecb\u7ecd\u53ef\u4ee5\u770b\u51fa\uff0cfileencoding \u662f\u5728\u6253\u5f00\u6587\u4ef6\u7684\u65f6\u5019\uff0c\u7531 Vim \u8fdb\u884c\u63a2\u6d4b\u540e\u81ea\u52a8\u8bbe\u7f6e\u7684\u3002\u56e0\u6b64\uff0c\u5982\u679c\u51fa\u73b0\u4e71\u7801\uff0c\u6211\u4eec\u65e0\u6cd5\u901a\u8fc7\u5728\u6253\u5f00\u6587\u4ef6\u540e\u91cd\u65b0\u8bbe\u7f6e fileencoding \u6765\u7ea0\u6b63\u4e71\u7801\u3002<\/p>\n

fileencodings<\/strong><\/p>\n

\u7f16\u7801\u7684\u81ea\u52a8\u8bc6\u522b\u662f\u901a\u8fc7\u8bbe\u7f6e fileencodings \u5b9e\u73b0\u7684\uff0c\u6ce8\u610f\u662f\u590d\u6570\u5f62\u5f0f\u3002fileencodings \u662f\u4e00\u4e2a\u7528\u9017\u53f7\u5206\u9694\u7684\u5217\u8868\uff0c\u5217\u8868\u4e2d\u7684\u6bcf\u4e00\u9879\u662f\u4e00\u79cd\u7f16\u7801\u7684\u540d\u79f0\u3002\u5f53\u6211\u4eec\u6253\u5f00\u6587\u4ef6\u7684\u65f6\u5019\uff0cVIM \u6309\u987a\u5e8f\u4f7f\u7528 fileencodings \u4e2d\u7684\u7f16\u7801\u8fdb\u884c\u5c1d\u8bd5\u89e3\u7801\uff0c\u5982\u679c\u6210\u529f\u7684\u8bdd\uff0c\u5c31\u4f7f\u7528\u8be5\u7f16\u7801\u65b9\u5f0f\u8fdb\u884c\u89e3\u7801\uff0c\u5e76\u5c06 fileencoding \u8bbe\u7f6e\u4e3a\u8fd9\u4e2a\u503c\uff0c\u5982\u679c\u5931\u8d25\u7684\u8bdd\uff0c\u5c31\u7ee7\u7eed\u8bd5\u9a8c\u4e0b\u4e00\u4e2a\u7f16\u7801\u3002<\/p>\n

\u56e0\u6b64\uff0c\u6211\u4eec\u5728\u8bbe\u7f6e fileencodings \u7684\u65f6\u5019\uff0c\u4e00\u5b9a\u8981\u628a\u8981\u6c42\u4e25\u683c\u7684\u3001\u5f53\u6587\u4ef6\u4e0d\u662f\u8fd9\u4e2a\u7f16\u7801\u7684\u65f6\u5019\u66f4\u5bb9\u6613\u51fa\u73b0\u89e3\u7801\u5931\u8d25\u7684\u7f16\u7801\u65b9\u5f0f\u653e\u5728\u524d\u9762\uff0c\u628a\u5bbd\u677e\u7684\u7f16\u7801\u65b9\u5f0f\u653e\u5728\u540e\u9762\u3002<\/p>\n

\u4f8b\u5982\uff0clatin1 \u662f\u4e00\u79cd\u975e\u5e38\u5bbd\u677e\u7684\u7f16\u7801\u65b9\u5f0f\uff0c\u4efb\u4f55\u4e00\u79cd\u7f16\u7801\u65b9\u5f0f\u5f97\u5230\u7684\u6587\u672c\uff0c\u7528 latin1 \u8fdb\u884c\u89e3\u7801\uff0c\u90fd\u4e0d\u4f1a\u53d1\u751f\u89e3\u7801\u5931\u8d25\u2014\u2014\u5f53\u7136\uff0c\u89e3\u7801\u5f97\u5230\u7684\u7ed3\u679c\u81ea\u7136\u4e5f\u5c31\u662f\u7406\u6240\u5f53\u7136\u7684\u201c\u4e71\u7801\u201d\u3002\u56e0\u6b64\uff0c\u5982\u679c\u4f60\u628a latin1 \u653e\u5230\u4e86 fileencodings \u7684\u7b2c\u4e00\u4f4d\u7684\u8bdd\uff0c\u6253\u5f00\u4efb\u4f55\u4e2d\u6587\u6587\u4ef6\u90fd\u662f\u4e71\u7801\u4e5f\u5c31\u662f\u7406\u6240\u5f53\u7136\u7684\u4e86\u3002<\/p>\n

\u63a8\u8350\u4e00\u4e2a fileencodings \u8bbe\u7f6e\uff1a<\/p>\n

set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1<\/p><\/blockquote>\n

\u5176\u4e2d\uff0cucs-bom \u662f\u4e00\u79cd\u975e\u5e38\u4e25\u683c\u7684\u7f16\u7801\uff0c\u975e\u8be5\u7f16\u7801\u7684\u6587\u4ef6\u51e0\u4e4e\u6ca1\u6709\u53ef\u80fd\u88ab\u8bef\u5224\u4e3a ucs-bom\uff0c\u56e0\u6b64\u653e\u5728\u7b2c\u4e00\u4f4d\u3002<\/p>\n

utf-8 \u4e5f\u76f8\u5f53\u4e25\u683c\uff0c\u9664\u4e86\u5f88\u77ed\u7684\u6587\u4ef6\u5916(\u4f8b\u5982\u8bb8\u591a\u4eba\u6d25\u6d25\u4e50\u9053\u7684 GBK \u7f16\u7801\u7684\u201c\u8054\u901a\u201d\u88ab\u8bef\u5224\u4e3a UTF-8 \u7f16\u7801\u7684\u7ecf\u5178\u9519\u8bef)\uff0c\u73b0\u5b9e\u751f\u6d3b\u4e2d\u4e00\u822c\u6587\u4ef6\u662f\u51e0\u4e4e\u4e0d\u53ef\u80fd\u88ab\u8bef\u5224\u7684\uff0c\u56e0\u6b64\u653e\u5728\u7b2c\u4e8c\u4f4d\u3002<\/p>\n

\u63a5\u4e0b\u6765\u662f cp936 \u548c gb18030\uff0c\u8fd9\u4e24\u79cd\u7f16\u7801\u76f8\u5bf9\u5bbd\u677e\uff0c\u5982\u679c\u653e\u524d\u9762\u7684\u8bdd\uff0c\u4f1a\u51fa\u73b0\u5927\u91cf\u8bef\u5224\uff0c\u6240\u4ee5\u5c31\u8ba9\u5b83\u4eec\u9760\u540e\u4e00\u4e9b\u3002cp936 \u7684\u7f16\u7801\u7a7a\u95f4\u6bd4 gb18030 \u5c0f\uff0c\u6240\u4ee5\u628a cp936 \u653e\u5728 gb18030 \u524d\u9762\u3002<\/p>\n

\u81f3\u4e8e big5\u3001euc-jp \u548c euc-kr\uff0c\u5b83\u4eec\u7684\u4e25\u683c\u7a0b\u5ea6\u548c cp936 \u5dee\u4e0d\u591a\uff0c\u628a\u5b83\u4eec\u653e\u5728\u540e\u9762\uff0c\u5728\u7f16\u8f91\u8fd9\u4e9b\u7f16\u7801\u7684\u6587\u4ef6\u7684\u65f6\u5019\u5fc5\u7136\u51fa\u73b0\u5927\u91cf\u8bef\u5224\uff0c\u4f46\u8fd9\u662f Vim \u5185\u7f6e\u7f16\u7801\u63a2\u6d4b\u673a\u5236\u6ca1\u6709\u529e\u6cd5\u89e3\u51b3\u7684\u4e8b\u3002\u7531\u4e8e\u4e2d\u56fd\u7528\u6237\u5f88\u5c11\u6709\u673a\u4f1a\u7f16\u8f91\u8fd9\u4e9b\u7f16\u7801\u7684\u6587\u4ef6\uff0c\u56e0\u6b64\u6211\u4eec\u8fd8\u662f\u51b3\u5b9a\u628a cp936 \u548c gb18030 \u524d\u63d0\u4ee5\u4fdd\u8bc1\u8fd9\u4e9b\u7f16\u7801\u7684\u8bc6\u522b\u3002<\/p>\n

\u6700\u540e\u5c31\u662f latin1 \u4e86\u3002\u5b83\u662f\u4e00\u79cd\u6781\u5176\u5bbd\u677e\u7684\u7f16\u7801\uff0c\u4ee5\u81f3\u4e8e\u6211\u4eec\u4e0d\u5f97\u4e0d\u628a\u5b83\u653e\u5728\u6700\u540e\u4e00\u4f4d\u3002\u4e0d\u8fc7\u53ef\u60dc\u7684\u662f\uff0c\u5f53\u4f60\u78b0\u5230\u4e00\u4e2a\u771f\u7684 latin1 \u7f16\u7801\u7684\u6587\u4ef6\u65f6\uff0c\u7edd\u5927\u90e8\u5206\u60c5\u51b5\u4e0b\uff0c\u5b83\u6ca1\u6709\u673a\u4f1a fall-back \u5230 latin1\uff0c\u5f80\u5f80\u5728\u524d\u9762\u7684\u7f16\u7801\u4e2d\u5c31\u88ab\u8bef\u5224\u4e86\u3002\u4e0d\u8fc7\uff0c\u6b63\u5982\u524d\u9762\u6240\u8bf4\u7684\uff0c\u4e2d\u56fd\u7528\u6237\u6ca1\u6709\u592a\u591a\u673a\u4f1a\u63a5\u89e6\u8fd9\u6837\u7684\u6587\u4ef6\u3002<\/p>\n

\u5982\u679c\u7f16\u7801\u88ab\u8bef\u5224\u4e86\uff0c\u89e3\u7801\u540e\u7684\u7ed3\u679c\u5c31\u65e0\u6cd5\u88ab\u4eba\u7c7b\u8bc6\u522b\uff0c\u4e8e\u662f\u6211\u4eec\u5c31\u8bf4\uff0c\u8fd9\u4e2a\u6587\u4ef6\u4e71\u7801\u4e86\u3002\u6b64\u65f6\uff0c\u5982\u679c\u4f60\u77e5\u9053\u8fd9\u4e2a\u6587\u4ef6\u7684\u6b63\u786e\u7f16\u7801\u7684\u8bdd\uff0c\u53ef\u4ee5\u5728\u6253\u5f00\u6587\u4ef6\u7684\u65f6\u5019\u4f7f\u7528 ++enc=encoding \u7684\u65b9\u5f0f\u6765\u6253\u5f00\u6587\u4ef6\uff0c\u5982\uff1a<\/p>\n

:e ++enc=utf-8 myfile.txt<\/p><\/blockquote>\n

VIM\u7f16\u7801\u8f6c\u6362\u5de5\u4f5c\u539f\u7406<\/strong><\/p>\n

\u5173\u4e8eVim\u7684\u652f\u6301\u591a\u5b57\u7b26\u7f16\u7801\u65b9\u5f0f\u5de5\u4f5c\u7684\u8fd0\u4f5c\u539f\u7406\u662f\uff1a<\/p>\n

\u9996\u5148\u3001Vim \u542f\u52a8\uff0c\u6839\u636e_vimrc\u914d\u7f6e\u6587\u4ef6\u4e2d\u8bbe\u7f6e\u7684encoding\u7684\u503c\u6765\u8bbe\u7f6ebuffer\u3001\u83dc\u5355\u6587\u672c\u3001\u6d88\u606f\u6587\u7684\u5b57\u7b26\u7f16\u7801\u65b9\u5f0f\u3002<\/p>\n

\u7d27\u63a5\u3001\u8bfb\u53d6\u8981\u7f16\u8f91\u7684\u6587\u4ef6\uff0c\u6839\u636efileencodings\u4e2d\u5217\u51fa\u7684\u5b57\u7b26\u7f16\u7801\u65b9\u5f0f\u9010\u4e00\u63a2\u6d4b\u8be5\u6587\u4ef6\u7f16\u7801\u65b9\u5f0f\u3002\u5e76\u8bbe\u7f6efileencoding \u4e3a\u63a2\u6d4b\u5230\u7684\u5b57\u7b26\u7f16\u7801\u65b9\u5f0f\u3002<\/p>\n

\u7136\u540e\u3001\u5bf9\u6bd4fileencoding\u548cencoding\u7684\u503c\uff0c\u82e5\u4e0d\u540c\u5219\u8c03\u7528iconv\u5c06\u6587\u4ef6\u5185\u5bb9\u8f6c\u6362\u4e3aencoding\u6240\u63cf\u8ff0\u7684\u5b57\u7b26\u7f16\u7801\u65b9\u5f0f\uff0c\u5e76\u4e14\u628a\u8f6c\u6362\u540e\u7684\u5185\u5bb9\u653e\u5230\u4e3a\u6b64\u6587\u4ef6\u5f00\u8f9f\u7684buffer\u91cc\uff0c\u5b8c\u6210\u540e\u5c31\u53ef\u4ee5\u5f00\u59cb\u7f16\u8f91\u8fd9\u4e2a\u6587\u4ef6\u3002<\/p>\n

\u6700\u540e\u3001\u7f16\u8f91\u5b8c\u6210\u540e\u4fdd\u5b58\u6587\u4ef6\u65f6\uff0c\u518d\u6b21\u5bf9\u6bd4fileencoding\u548cencoding\u7684\u503c\u3002\u82e5\u4e0d\u540c\u518d\u6b21\u8c03\u7528iconv\u5c06\u5373\u5c06\u4fdd\u5b58\u7684buffer\u4e2d\u7684\u6587\u672c\u8f6c\u6362\u4e3afileencoding\u6240\u63cf\u8ff0\u7684\u5b57\u7b26\u7f16\u7801\u65b9\u5f0f\uff0c\u5e76\u4fdd\u5b58\u5230\u6307\u5b9a\u7684\u6587\u4ef6\u4e2d\u3002<\/p>\n

\u6ce8\uff1a\u9700\u8981\u8c03\u7528\u5916\u90e8\u7684iconv.dll\uff0c\u9700\u8981\u4fdd\u8bc1\u8fd9\u4e2a\u6587\u4ef6\u5b58\u5728\u4e8e$VIMRUNTIME\u6216\u8005\u5176\u4ed6\u5217\u5728PATH\u73af\u5883\u53d8\u91cf\u4e2d\u7684\u76ee\u5f55\u91cc\u3002<\/p>\n

\u8d34\u4e00\u4e2a\u6211\u5904\u7406\u4e2d\u6587\u95ee\u9898\u7684\u914d\u7f6e\uff1a<\/p>\n

\n
\"\u4e2d\u6587\u4e71\u7801\u95ee\u9898\r\nset encoding=utf-8\r\nset fileencodings=utf-8,chinese,latin-1\r\nif has(\"win32\")\r\n\tset fileencoding=chinese\r\nelse\r\n\tset fileencoding=utf-8\r\nendif\r\n\"\u89e3\u51b3\u83dc\u5355\u4e71\u7801\r\nsource $VIMRUNTIME\/delmenu.vim\r\nsource $VIMRUNTIME\/menu.vim\r\n\"\u89e3\u51b3consle\u8f93\u51fa\u4e71\u7801\r\nlanguage messages zh_CN.utf-8<\/pre>\n<\/blockquote>\n

\u5f53\u524dVIM\u6d4b\u8bd5\u73af\u5883\uff1agvim 7.3.46 win7 x64<\/em><\/p>\n


\n\u53c2\u8003\u8d44\u6599:<\/strong>
\nhttp:\/\/edyfox.codecarver.org\/html\/vim_fileencodings_detection.html
\n<\/a>
http:\/\/www.liuhuadong.com\/archives\/68\/index.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

Win7\u5bf9\u7cfb\u7edf\u5185\u5b58\u7684\u8d2a\u5a6a\u7ec8\u4e8e\u8ba9\u6211\u4e0b\u5b9a\u51b3\u5fc3\u4f7f\u7528VIM\u4f5c\u4e3a\u5de5\u4f5c\u7f16\u8f91\u5668\u4ee3\u66ff\u4e86\uff0c2G\u5185\u5b58Win7\u4e0b\u5f00\u4e2aZendstud […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20],"tags":[65,66],"_links":{"self":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1483"}],"collection":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/comments?post=1483"}],"version-history":[{"count":3,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1483\/revisions"}],"predecessor-version":[{"id":1485,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1483\/revisions\/1485"}],"wp:attachment":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/media?parent=1483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/categories?post=1483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/tags?post=1483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}