space/tab conversion utility?

Grant Edwards grante at
Thu Jul 29 16:32:37 CEST 2004

On 2004-07-29, Catalin Marinas <catalin.marinas at> wrote:

>> So that I can submit patches to a Python application whos
>> devloper uses tabs.  My Python editor uses spaces.
> You have different options to the diff command for this:
>   -E  --ignore-tab-expansion  Ignore changes due to tab expansion.
>   -b  --ignore-space-change  Ignore changes in the amount of white space.
>   -w  --ignore-all-space  Ignore all white space.
>   -B  --ignore-blank-lines  Ignore changes whose lines are all blank.

But the lines of code I added will still be indented with
spaces, and the program's author uses tabs.

> Otherwise, a simple sed script might do it (convert 4 spaces
> to one tab for example):
>   sed -e "s/    /\t/g/"

Nope, that doesn't work for reasons already discussed.  Even if
you restrict it to spaces at the beginning of the line (e.g.
unexpand -t4 --first-only) it still breaks things.

Grant Edwards                   grante             Yow!  I just remembered
                                  at               something about a TOAD!

More information about the Python-list mailing list