Tab wars revisited (was Re: Python indentation)

Mark 'Kamikaze' Hughes kamikaze at kuoi.asui.uidaho.edu
Thu Jul 8 19:00:06 EDT 2004


Istvan Albert <ialbert at mailblocks.com>
wrote on Wed, 07 Jul 2004 17:13:38 -0400:
> Peter Hansen wrote:
>> Ambiguity sucks but a SPACE is a SPACE is a SPACE.
> Is there a reason why a TAB is not a TAB is not a TAB?

foo
    bar
        baz
    quux
 	wibble
pting

  One of those indentation levels is not like the others.  Guess which
one!

>> *Any* decent editor can be configured to inject spaces up to the
>> next defined tab-stop when TAB is hit.  By definition, therefore,
>> any editor that cannot is broken.
> Is it really that trivial to set up an editor so that when one hits
> delete/backspace to 'un-align' a line of code it deletes as
> many space characters as the soft-tab has inserted?
> I don't think so.

  You think wrong.  Basically every programmer's editor does that, quite
easily, and has for decades--it's been at least 20 years since I've seen
an editor that didn't.

  In Vim:
set sw=4 sta et ai bs=2

  Put that in your .vimrc, and you're done.  The key labelled Tab is now
just a convenient way of specifying "indent the standard four spaces",
and backspace on leading spaces removes the last four.  Done.

  Nobody would accuse Vim of being the easiest editor in the world to
learn or configure, but you learn that the way you learn anything about
it: you ask a local guru who tells you, or you type :help just like it
says when it starts up without a file.

  Other editors are easier--less powerful, but easier.  Most come with
that behavior turned on by default, or with a pretty checkbox option on
their pretty GUI option page.

  You have confused tabulation, which is an ancient display hack for
terminals, with indentation, which is a representation of nesting depth.
They're separate concepts.  You can use tabulation for indentation, but
as my example above shows, that's very error-prone.

-- 
 <a href="http://kuoi.asui.uidaho.edu/~kamikaze/"> Mark Hughes </a>
"The void breathed hard on my heart, turning its illusions to ice, shattering
 them.  Was reborn, then, free to scrawl own design on this morally blank
 world.  Was Rorschach." --Alan Moore, _Watchmen #6_, "The Abyss Gazes Also"



More information about the Python-list mailing list