How can I change a file's encoding with vim?
From the doc:
:write ++enc=utf-8 russian.txt
So you should be able to change the encoding as part of the write command.
Notice that there is a difference between
set encoding
and
set fileencoding
In the first case, you'll change the output encoding that is shown in the terminal. In the second case, you'll change the output encoding of the file that is written.
While using vim to do it is perfectly possible, why don't you simply use iconv? I mean - loading text editor just to do encoding conversion seems like using too big hammer for too small nail.
Just:
iconv -f utf-16 -t utf-8 file.xml > file.utf8.xml
And you're done.