Fix Python source code to use spaces instead of tabs
What if someone gave you a Python source file that is indented using tabs? If you are using emacs, the following commands will let you convert it back to using spaces:
# first set the buffer tab width to 4 (or whatever you like) M-x set-variable <return> tab-width <return> 4 # then mark the entire file C-x h # do untabify to convert: M-x untabify <return>
That’s it!
I had to do this on my own sources 🙁 a while back but used find and sed 🙂
http://trevershick.tumblr.com/post/2150488289/the-most-useful-command-of-the-night-find
for vi users – put in your ~/.vimrc file
set ts=4
set expandtab
then to get rid of existing tabs in a file use an inplace sed script
:1,$s/^I/ /g
the “^I” is actually but will output as ^I