Tom Link 写道:
> 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?
> 
> Regards,
> Thomas

In order to be able to edit different file encodings you must set the 
'fencs' option. The 'fencs' option specifies encodings to try when 
opening an existing file, you can set it to :set 
fencs=ucs-bom,utf-8,latin1, this auto-detection works for existing file.

for the new file, the encoding will be set to 'enc', so it would 
generally be in utf-8, if you want to save the file in latin1, simply 
:set fenc=latin1 before you save the file. and the file will be saved as 
latin1. next time when you open the file it will be recognized as latin1.

if your file contains only ascii characters, it will be detected as 
utf-8, will in most cases doesn't matter too much, you can always change 
the file encoding on-the-fly.



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

Reply via email to