Slashdot Mirror


Elastic Tabstops — An End to Tabs vs. Spaces?

An anonymous reader writes "Along with Vi versus Emacs, the tabs versus spaces argument must rank as one of the classic holy wars among coders. Here's an attempt to solve it by making tabstops expand or shrink to fit their contents. The concept's pretty cool to use, so be sure to have a play with the demo!"

4 of 263 comments (clear)

  1. How we got here by Animats · · Score: 4, Interesting

    The way we got into this mess is that in early versions of UNIX, tab stops were set to 8 spaces in the TTY handler. This was not because tab stops were intended as indentation. It was because an ASR-33 teletype could tab that far in one character time. It was for optimizing output time. (Back in those days, TTY output processing had to have time delays to handle the mechanical lag in printers. "How many nulls were required after each carriage return" was an issue, and better systems kept track of the printing column position and adjusted the delay accordingly. Peripherals used to be really dumb.)

    If some reasonable indentation value like 4 or 5 had been chosen, everything would have been fine.

    1. Re:How we got here by Mr+Z · · Score: 3, Interesting

      Not just mechanical output devices. I wrote a TTY driver for a Viewpoint terminal that I was driving from an 8052. That thing needed delays all over the place. (Imagine my surprise, years later, to open one up and find an 8051 sitting in there.) I actually discovered it needed delays from the UNIX side of things, because the first thing I implemented was a serial-to-serial pass through, and I had to mess w/ the various stty delay settings before I stopped losing text.

      But, yes... 80 columns goes back to Hollerith, and 8-column tabs goes back to an old teletype.... and yet these standards persist. :-) I personally expand all tabs to spaces just to avoid tab damage. I've gotten some horribly dainbramaged files over the years and never like being on the receiving end of that.

      --Joe
  2. Re:From Wiki by DesertWolf0132 · · Score: 3, Interesting

    Vi came to fulfil the law of Ed as Christ came to fulfil the law of Moses. Come forth into the baptism of the Holy Vi and be saved!

    --
    No animals were harmed in the making of this sig.
    Well, there was that one puppy, but he is all better now.
  3. Re:A standard tab length would be easier by swansontec · · Score: 3, Interesting

    This is how I code, at least in C-like languages. You can set your tab length to whatever you want, and my sources still look pretty:

    int foo ()
    {
        //Every line starts with tabs:
        if (
            some_really_long_expression &&
            some_other_really_long_expression
        ) {
            DoSomethingClever(42);
            DoSomethingComplex(
                param1,         //Tabs start the line, spaces between param and comment
                param2,         //Comments line up, thanks to spaces
                param3          //Tab can be any length, whole line moves in or out
            );
            return -1;
        } else {
            return rand();
        }
    }