Ruby: how to add "# encoding: UTF-8" automatically? Ruby: how to add "# encoding: UTF-8" automatically? ruby ruby

Ruby: how to add "# encoding: UTF-8" automatically?


Upgrade to Ruby 2.0, as it makes UTF-8 the default encoding, removing the need for magic comments.


Try magic_encoding gem, it can insert uft-8 magic comment to all ruby files in your app.

[EDIT]Having switched to SublimeText now I use auto-encoding-for-ruby plugin.


Vim:

:args **/*.ruby:set hidden:argdo norm! O# encoding: UTF-8:wqa