Calvin Cheng
Calvin Cheng

Reputation: 36506

vim buffer Trying char-by-char conversion

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?

Upvotes: 2

Views: 93

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172590

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.

Upvotes: 5

Related Questions