Using tabs effectively. Was: Why not use tabs?

Joe Smith JoeSmith at bogusaddress.com
Tue Jan 25 04:46:29 EST 2000


I was assuming that that tabs were for getting to the first real (significant)
character in the line.  Spaces need to be used after the first character in the
line (I neglected to mention this).  This allows any tab setting to work.  So in
your case you would use spaces after the A.  I assume your example is for aligning
variables or and equal signs.
    xyz = abc
    x    =  dfk
    int  x;
    long y;

This netscape thing is not doing the right thing for me, but tab is the first
character and the two ='s should be vertically aligned and the x and the y should
be verticly aligned.

I am definitely not talking about anything other than programming type of code.

James Logajan wrote:

> Joe Smith wrote:
> >
> > If one is using all tabs, then putting a comment at the top of the file
> > indicating the tab setting seems like a waste.  If one is mixing tabs and
> > spaces, then it is needed.  Maybe the comment should be one of the following:
> > using all tabs, using all spaces or mixing with a tab setting of X.
>
> Unfortunately, this wont work in general. You may be forgetting that tabs
> may also be embedded. For example, consider a file that contains the
> following text lines, where ^I indicates a tab:
>
> A^I^Ix
> AA^I^Ix
> AAA^I^Ix
> AAAA^Ix
> AAAAA^Ix
> AAAAAA^Ix
> AAAAAAA^Ix
>
> The intent is to have that look like:
>
> A       x
> AA      x
> AAA     x
> AAAA    x
> AAAAA   x
> AAAAAA  x
> AAAAAAA x
>
> There is only ONE tab setting that will produce that result. You would have
> to be either very clever, plow through the possibilities, or be told (via a
> comment) for you to discover the original tab setting. (The discovery of the
> tab setting used in the example is left as an exercise for the reader.)
>
> Hopefully that explains the reason for my desire to see a comment at the top
> of all source files indicating the tab setting, even when spaces aren't
> being used.




More information about the Python-list mailing list