On Thu, Nov 13, 2008 at 9:25 AM, A. S. Budden wrote:
>
> 2008/11/13 James Kanze:
>>
>> How does vim decide what encoding(s) to use when it opens an
>> existing file?
>>
>> I ask this because in the past, with text files, it seems to
>> have "just worked", and with C++ files and shell scripts, it
>> never mattered, since they only contained ASCII.  However, I've
>> now got some C++ files which have French (with accents) in their
>> comments.  The standard header that we use (copyright, etc.) is
>> in English, as is all of the program text itself, which means
>> that there is a large block of pure ASCII at the start.  I'm
>> gradually converting everything from Latin 1 to UTF-8, however;
>> I use vim for the conversion (read, change fileencoding,
>> rewrite), which works fine, but the next time I read the file,
>> vim still treats it as if it were Latin 1 unless I manually
>> change encoding (and fileencoding?)
>>
>> As far as I can tell, I've nothing in any of my configuration
>> files which specify an encoding.

It's all documented in painful detail at :help 'fencs'

You should definitely not be changing 'encoding' once vim is already
up and running, it should only ever be set once before any buffers are
read.  It will be populated by your locale, assuming you have a .UTF-8
locale and multi-byte support compiled into vim, otherwise you should
set it to something that's a superset of every other character set
you'll want to use in your ~/.vimrc.

> This doesn't answer your question, but have you considered adding a
> modeline to the end of the files, something like:
>
> /* vim:set encoding=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.

~Matt

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to