Converting all files to tab indentation from spaces

Tabs are clearly the one true indentation style, but when you create a new Ruby on Rails project it uses spaces, which could lead to a mish-mash of tabs and spaces in your project, not good!

The solution? Convert them using this one simple trick from the root of the project:

for i in `find app -name *.rb`; do echo $i; cat $i | unexpand -t2 > $i.converted; mv $i.converted $i; done

Repeat as necessary for other directories (test, config etc.) and other file types (erb).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s