VIM 中的 UTF-8 编码
我在编辑时在 vim 中使用 UTF-8 字符没有问题,但是当我 set fileencoding=utf-8
然后保存并重新加载文件时,vim 错误地显示非 ASCII 字符。
为什么会发生这种情况,以及如何解决这个问题?
I have no problem with UTF-8 chars in vim while editing, but when I do set fileencoding=utf-8
and then save and reload the file, vim displays nonascii chars incorrectly.
Why is that happening, and how to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
'fileencodings'
设置的值是多少?此设置确定 Vim 尝试使用哪些编码来解释正在加载的缓冲区的内容。假定第一个不会导致转换错误的编码是当前文件的编码。如果要测试 utf8,您应该将其放在该设置的开头。
例如,您可能将
fileencodings
设置为latin1
。此编码始终有效(没有可以拒绝的单字节组合)。如果您不想更改
文件编码
,您可以使用以下命令重新加载文件::e! ++enc=utf8
What is the value of your
'fileencodings'
setting? This setting determines what encodings are tried by Vim to interpret the contents of a buffer that is being loaded. The first encoding that does not result in a conversion error is assumed to be the current file's encoding.If
utf8
is to be tested you should put it at the beginning of that setting.Probably you have
fileencodings
set tolatin1
for example. This encoding is always valid (there is no single byte combination that could be rejected).If you don't want to change
fileencodings
you can reload the file with::e! ++enc=utf8