About four years ago I had to fiddle with Vim to make it edit an UTF-8 encoded file, while my terminal (and system) used ISO-8859-2.
I use UTF-8 as the default encoding today. How to edit with Vim an ISO-8859-2 file when my system uses UTF-8?
The first thought was to make it the same way as before, just swapping the parameter values: set encoding to ISO-8859-2 and termencoding to UTF-8. Unfortunately, it doesn’t work!
After some RTFM’ing, I learned about the fileencoding parameter, but setting it to ISO-8859-2 didn’t fix the problem. This was to be solved in a different way.
Vim will automatically guess the file encoding, as long as the encoding is listed in the fileencodings parameter. I use only UTF-8 AND ISO-8859-2 (alias LATIN2) encodings, so adding following line to the ~/.vimrc file fixed the problem: