Monthly Archives: January 2019

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).