Friday, February 01, 2013

Replace tabs by whitespace across multiple files

A new member of the team did a great job refactoring several JSP files however he had set his editor to use literal tabs and our current code style is to use 4 literal spaces whenever you use tab.

I couldn't help myself proposing to use Unix Power Tools to resolve this issue. So here is the one liner that corrected all JSP files. Here are two options, one with perl and the other without it:
find ./jsp/ -name "*.jsp" | xargs perl -p -i -e 's/\t/    /g'
find ./jsp/ -name "*.jsp" | xargs sed -i 's/\t/    /g'

No comments: