Quickly change a files encoding using vi

Ever needed to change a files encoding? One example would be to display characters in other languages properly on a website. Here’s a simple vi trick to do just that:

vi filename.php
:set bomb
:set fileencoding=utf-8
:wq

 
Note: to find the encoding of a file:

file -bi <file name>

Share this Post