Indenting with tabs vs spaces

Steve Lamb grey at despair.dmiyu.org
Sat Dec 1 00:10:44 CET 2001


On Thu, 22 Nov 2001 03:58:08 -0800, Peoter Veili <peoter_veliki at hotmail.com> wrote:
> Indenting with tabs can be done such that it will look the same on every
> editor that uses fixed-width fonts, meaning everything will line up
> correctly, it least in the sense that really matters.  Here's an example of
> what I mean:

    Uhhh....

>     function helloThere("hello",
>                                        "there"){
>     }

    ...no.

> The proper way to do this is the second line needs to be typed with one tab
> followed by enough spaces to line up the "hello" and "there".  

    A tab is a variable.  I have tab set to 2 spaces.  You have it set to 8.
So by your logic you hit tab + 32 spaces.  To you that would b 40 spaces.  To
me that is 32.  40 != 32, even for large values of 32.

> This way the "hello" and "there" will line up correctly on any editor. If
> the person was lazy and tabbed all the way out to right before "there" and
> then filled in with a few spaces, it may not line up depending on what your
> tabwidth is set to.

    Which is what happens if you use a single tab or 32 tabs.  A space is a
space.  1=1.  All others are variable.

> Besides this I know of no problems with using tabs.  I find them cleaner and
> more efficient.  I'd rather tab 10 times than hit the space bar 40 times. I
> never have to go through a whole file and manually line things up because at
> one place in the file I accidentally didn't indent with the right amount of
> spaces and half the file needs fixing.  Auto-indent helps, but still....

    So does moving blocks back and forth (>> and << in vim, ^K> and ^K< in
Joe, etc...).  Mark the beginning, mark the end, move block.  No biggie.  As
for hitting space 40 times or tab 10 I rather hold down the space bar once.

-- 
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
         ICQ: 5107343          | main connection to the switchboard of souls.
    To email: Don't despair!   |  -- Lenny Nero, Strange Days
-------------------------------+---------------------------------------------



More information about the Python-list mailing list