How to change encoding of a file with vim? (example: to utf8)

This is actual pretty easy, with vim, you just need to run the following command:

:write ++enc=utf-8 utf8.txt

This will let vim write the same file into utf8.txt with UTF-8 encoding.

As an alternative you can also use iconv:

iconv -f utf-16 -t utf-8 file.txt > utf8.txt

You cannot comment on this entry