Monday, September 22, 2008

Encoding|Batch file encoding conversion with Vim

Batch file encoding conversion with Vim

Publication date
03/27/2007
Categories
, ,
$ ex filename '+set fenc=utf-8' '+x'

It's basically the same to opening the file using vim, change its encoding (set fenc=utf-8), save (if needed) and quit (x).

The advantage over using other methods (like iconv) is that vim will try to detect automatically the current file encoding.

So, for example you can change all you .html files to Unicode at the same time:

$ find -name '*.html' -exec ex {} '+set fenc=utf-8' '+x' \;

No comments: