Sunday, October 24, 2010

enc,fenc (again!?)

Hi, all.

I know that this has been discussed for a long time but I still don't
understand why Vim behaves like that.

Some times I need to work with several buffer. Some in natural 'utf-8'
encoding. I say natural because it is the system default (I am in a Mac) and
is defined in Vim 'encoding' option. But some buffer I need to be in 'latin1'.
Opening the files in the right encoding is easy, since I use the '++enc'
option. So the files are read correctly. The problem begins when I use
'bnext' and 'bprevious' (or another similar command) to navigate between the
buffers. Since my encoding is 'utf-8', when I navigate from a buffer with this
encoding to a buffer that was opened with '++enc=latin1' this buffer get its
encoding changed to 'utf-8'.

I am trying to solve this problem for a long time and never accomplished it.
What I can't understand is why Vim ignores the buffer 'fileencoding' variable?
It is set correctly and is set when the buffer is opened. To be sure about
that I manually set the 'fileencoding' variable when the buffer is opened.

Let me explain this right. I open a file with '++enc=latin1'. In the 'BufRead'
auto command I set the 'fenc' variable as this: call setbufvar('%', '&fenc',
'latin1').

Then I navigate to another buffer that is in another encoding (like 'utf-8').
When I come back to the first buffer, its 'fenc' variable is 'utf-8' and I
don't understand why!

My current global configuration is as follows:

encoding=utf-8
fileencodings=ucs-bom,utf-8,default,latin1
fileencoding=utf-8

--
Alessandro Antonello

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment