Hi Klaus :)

 * Klaus Ethgen <[EMAIL PROTECTED]> dixit:
> I think that question was asked many time before but with differed
> direction but maybe there is someone having a answer. (I found some for
> the other direction not for mine.)

    I asked more or less the same a few days ago, you can see the thread
in the mailing list archive.
 
> Is there any way to only use utf8 if there are utf8 characters in the
> file (or explicite set)? Like the unix command "file -i" can choose?

    You can use 'file -i' in a "BufReadPost" autocommand and set the
appropriate variables from it, but that won't work for empty files, so
if you edit a new file and put latin1 characters on it, they will be
encoded as utf8 if you set "fileencodings=ucs-bom,utf8,latin1". So,
I've chosen a different approach. Since 99% of the files I work with are
latin1, I've set my vimrc like this:

    set encoding=default
    set fileencoding=
    set fileencodings=

    You can set the last one to "ucs-bom,latin1" if you want, that makes
no difference for me because I don't use files with 'bom'.

    After that, I've set up this mappings to switch manually from one
encoding to other:

 noremap  <silent> <Leader>+ :setlocal fenc=utf8 enc=utf8<CR>
 noremap  <silent> <Leader>- :setlocal fenc=latin1 enc=latin1<CR>

    OK, this is not a perfect solution, and it's a bit crappy and can be
automated (for example, using "file -i") but it works for me and I find
it very comfortable to use.

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
It's my PC and I'll cry if I want to... RAmen!

Reply via email to