VIM 中的 UTF-8 编码

发布于 2024-12-11 22:59:55 字数 140 浏览 0 评论 0原文

我在编辑时在 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技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初见你 2024-12-18 22:59:55

您的 '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 to latin1 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文