On Wed, Sep 23, 2009 at 1:07 AM, Tom Link wrote:
>
> Hi,
>
> Is there a way to set the fenc option from an autocommand so that I
> would get the same effect as if I opened the file with :edit +
> +enc=utf8 FILENAME
>
> The background: I usually use (f)enc=latin1 but would like to edit the
> files in a certain directory with fenc=utf8. I currently reopen the
> file with the above :edit command but I'm certain there is a better
> solution. Any ideas?

You can use an autocmd for that directory, but not a modeline.  For
vim to interpret the modeline, it has to read and understand the file,
and for it to do that, it needs to know the encoding.  Chicken and egg
problem.  By the time the modeline is read and interpreted, vim has
already chosen an encoding to read the file with. Setting fenc at that
point would change the format it would be *saved* as, but it's too
late to change what it's *read* as.

But, like I said, a BufRead,BufNewFile autocmd for that directory
would do the trick.

OTOH, if I were you, I'd be moving my way away from latin1 - utf8 is
much more pleasant to work with and move between people, in my
experience.

~Matt

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

Reply via email to