Convert multiple files from latin1 to utf8 with vim

If you have several files that need to be converted to utf8, you can do it with vim.

First start vim with:

$ vim $(find . -type f -iname '*.htm*')

Which will find all .htm and .html files from the current directory.

Then in vim, use : to go into command mode.

Run these two commands:
:set nomore
:bufdo set fileencoding=utf8 | w

Reference:
https://stackoverflow.com/questions/4544669/batch-convert-latin-1-files-to-utf-8-using-iconv

Leave a Reply

Your email address will not be published. Required fields are marked *