> That's probably part of the problem. I've got a somewhat mixed > locale, with LC_CTYPE set to iso_8859_1. (There are no UTF-8 > locales installed on the machine here. But since I move my code > between many machines, UTF-8 seems to be the more portable > solution.)
Yeah. UTF-8 is a good idea. If you're not using gvim, when you set enc in your .vimrc you may also need to set tenc so Vim plays nicely with your terminal. Something like :let &tenc=&enc :set enc=utf-8 >> Like I said above: don't change encoding when vim is running. >> It can invalidate internal strings and buffer text if you do >> that. > > Because it's a global setting? More because it affects *all* text in Vim, and the text isn't converted when you change the setting, it's just corrupted. :-) > If I did something like that with fileencoding=utf-8, would it > work? Or would vim only see it too late? It would work for the next time you save the file, but wouldn't reload the file, so it wouldn't set the encoding the file is read with. Use ++enc as I wrote in my previous email for that. > Also, supposing I set fileencodings=ucs-bom,utf-8,latin1, how > far into the file will vim read before committing to one > particular encoding? It won't commit until it's read the whole file successfully (or it's run out of encodings to try). Be careful if you rely on the encoding being detected by a special character in the file, though. What if you read a file with no such character, and then add one, or paste one from another file. The file will then be saved with the wrong encoding because it didn't detect the encoding you wanted. You may prefer to look into using some autocommnds to set the encoding for certain file types and/or locations. > I presume that the BOM testing only concerns the first 4 bytes, I think it can be up to 6. But I don't really know. I could look it up, but I couldn't be bothered. It doesn't matter. Yes, it's only a few bytes and the BOM detection will fail after that and fall through to the next of the fencs encodings. > For the moment, then, I'm adding: > set encoding=utf-8 fileencodings=ucs-bom,utf-8,latin1 > to my .vimrc. Looks good. Be aware of the tenc thing I mention above. Ben. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
