Detabbing files
01 January 2000
in code
tagged with
[utility]
A perl snippet to replace tabs by spaces, but the ‘right’ way, inserting enough spaces to bring the text up to the nth column.
The regular expression to do this is:
s/\t/" "x(8-(length($&)%8))/eg
To detab every file in this tree, recursively:
grep "\\t" -lr | xargs perl -pi -e 's/\t/" "x(8-(length($)%8))/eg'