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

Daniel Urstöger
04-06-2010 22:37

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


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


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"



Average rating: 0 (0 Votes)

You cannot comment on this entry