vim buffer Trying char-by-char conversion

痴心易碎 提交于 2019-12-24 02:42:41

问题


It could be a windows saved file opened in unix/linux problem and I am not quite sure how to solve it.

When I open a file which was previously saved by another developer using windows, my vim buffer some times shows

Trying char-by-char conversion...

In the middle of my file and I am unable to edit the code/text/characters right below this message in my buffer.

Why does it do that and how do I prevent this from happening?


回答1:


This message comes from the Vim function mac_string_convert() in src/os_mac_conv.c. It is accompanied by the following comment:

conversion failed for the whole string, but maybe it will work for each character

Seems like the file you're editing contains a byte sequence that cannot be converted to Vim's internal encoding. It's hard to offer help without more details, but often, these help:

  1. Ensure that you have :set encoding=utf-8
  2. Check :set filencodings? and ensure that the file you're trying to open is covered, or explicitly specify an encoding with :edit ++enc=... file
  3. The 8g8 command can find an illegal UTF-8 sequence, so that you can remove it, in case the file is corrupted. Binary mode :set binary / :edit ++bin may also help.


来源:https://stackoverflow.com/questions/14454901/vim-buffer-trying-char-by-char-conversion

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!