How to change file encoding to utf-8 via vim?


There are a few ways to achieve that, here is for a single file:

 

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

 

This way is a bit more automated:

vi --run-command=':set bomb, :set fileencoding=utf-8' filename.php"

 

And here is a way for various files:

vim +"set bomb | set fileencoding=utf-8 | wq" $(find . -type f -name *.php)

 

that will also work:

find . -type f -name *.php | xargs vim +"argdo set bomb | set fileencoding=utf-8 | w"

 

Enjoy!

Last update:
04-06-2010 22:37
Author:
Daniel Urstöger
Revision:
1.0
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.