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!"

12 of 263 comments (clear)

  1. Re:A standard tab length would be easier by Jeremi · · Score: 4, Insightful
    I think this is the wrong kind of solution to the problem. A standard would be easier. Just have someone say "Tabs are now officially SOME_NUMBER spaces long, so fuck you."


    You might as well tell the world "Earth's official language is now officially Esperanto, so fuck you". The effect would be about the same.

    --


    I don't care if it's 90,000 hectares. That lake was not my doing.
  2. From Wiki by neonprimetime · · Score: 4, Funny

    Use of the term "Holy War" implies that the root of the disagreement is a clash of values, and intractible of resolution except by agreeing to disagree.

    My bible says it is morally wrong to use Vi.

    1. Re:From Wiki by DesertWolf0132 · · Score: 5, Funny

      Mine says,

      "And behold sayeth the Lord, thou shalt edit thine text in Vi and Vi alone, even when thou art forced by the unclean luser to useth the operating system of unholiness. Thou shalt always keep a copy of the Holy editor on thine key of the USB lest thou shalt fall into temptation and edit thine text in the way of the unclean. Any who useth Emacs or the accursed notepad shalt be stricken from the Book of the Holy Sysadmin for all eternity. So sayeth the Lord." -1st Epistle to the Admins of Systems 1:15-16

      There it is in black and white. Vi is the way of truth and light. All others are unclean.

      --
      No animals were harmed in the making of this sig.
      Well, there was that one puppy, but he is all better now.
  3. 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.

  4. Re:A standard tab length would be easier by linvir · · Score: 4, Funny

    I move that we temporarily adjourn proceedings and reconvene on Thursday of next week, for the dupe.

  5. Re:A standard tab length would be easier by Daniel_Staal · · Score: 5, Insightful

    Actually, it is attempts to do that which have created the current confusion. Some were obviously too long, some obviously too short, and the end result is tabs which aren't useful.

    I actually like this idea, because it actually you from using this seemingly-simple but in actuality horribly complicated idea that tab = x*space. Instead they have an actually simple idea: Each tab is a seperate column of text. Line up items in the same column with each other. (Of course, how simple this is in practice is yet to be deterimined, but it seems simpler to me.)

    This idea is actually about seperateing sementic and content info. Programmers use tabs (those who do) to convey sementic info. If we can make the program understand that, then we can offer more flexiblity to the user on how to present the information.

    --
    'Sensible' is a curse word.
  6. Re:A standard tab length would be easier by GroeFaZ · · Score: 4, Informative

    Anyone know of an editor that has this?

    If you want that from an IDE, eclipse does that, and pretty robustly at that. I wouldn't want to miss it.

    For more simple editors for a quick text edit, my favorite is EditPlus. It lets you choose between classical tabs and whitespace tabs, as how long (in characters) a tab in either mode should be treated, it has the auto-indent you mentioned, reacting to freely definable characters (for example, auto-indent forward after '{' or '(', and back after '}' or ')', respectively). Best of all, it lets you define these parameters independently for plain text, c/c++, java, HTML, Perl, etc., etc., as well as any number of custom syntaxes you may wish to import or define yourself. A small selection of useful features of a great tool. Disclaimer: I am in no way affiliated with Editplus or the company behind it, just a happy user.

    --
    The grass is always greener on the other side of the light cone.
  7. Re:A standard tab length would be easier by peterpi · · Score: 4, Insightful
    I can't understand why people still find this a problem. It's so simple. Tabs indent, spaces line up. In other words

    • space means "move to the right by exactly one character width"
    • tab means "I want to indent, move across a bit". "A bit", and "across" mean whatever you like. It could be right8 chars, right 4 chars, left 2 chars, down 947565 chars, whatever you like. That's the beauty of it; everybody gets to view it in their favourite format.


    It's so simple, it's quite embarassing for the whole of the computer-literate society that people still get their kickers in a twist about it.

    Anybody who tries to lay down the law by saying that a tab must be 4, 8 or 2 characters' width has missed the point of the tab key completely.

    As for your wish, I'm willing to bet money that either vim or emacs will do it for you.

  8. The subject of tabs vs spaces should be clear by frn123 · · Score: 4, Insightful

    The subject of tabs vs spaces should be clear enough to everyone.

    Let me quote the relevant standard:

    Linux kernel coding style
    [cut]
    First off, I'd suggest printing out a copy of the GNU coding standards,
    and NOT read it. Burn them, it's a great symbolic gesture.
    [cut]
                      Chapter 1: Indentation

    Tabs are 8 characters, and thus indentations are also 8 characters.
    There are heretic movements that try to make indentations 4 (or even 2!)
    characters deep, and that is akin to trying to define the value of PI to
    be 3.

    Rationale: The whole idea behind indentation is to clearly define where
    a block of control starts and ends. Especially when you've been looking
    at your screen for 20 straight hours, you'll find it a lot easier to see
    how the indentation works if you have large indentations.

    Now, some people will claim that having 8-character indentations makes
    the code move too far to the right, and makes it hard to read on a
    80-character terminal screen. The answer to that is that if you need
    more than 3 levels of indentation, you're screwed anyway, and should fix
    your program.

    In short, 8-char indents make things easier to read, and have the added
    benefit of warning you when you're nesting your functions too deep.
    Heed that warning.

    [cut]
    But even if you fail in getting emacs to do sane formatting, not
    everything is lost: use "indent".

    Now, again, GNU indent has the same brain dead settings that GNU emacs
    has, which is why you need to give it a few command line options.
    However, that's not too bad, because even the makers of GNU indent
    recognize the authority of K&R (the GNU people aren't evil, they are
    just severely misguided in this matter), so you just give indent the
    options "-kr -i8" (stands for "K&R, 8 character indents").

    "indent" has a lot of options, and especially when it comes to comment
    re-formatting you may want to take a look at the manual page. But
    remember: "indent" is not a fix for bad programming.

    Linus Torvalds.

  9. Consistency is better than religion by morrison · · Score: 4, Insightful

    For several large projects I work with where there are lots of developers, consistency of the source code is considerably more important than any particular developer's opinion on what the correct behavior of tabs and spaces are. These are projects where it is pretty much expected that there are or will at least eventually be developers that use both vi and emacs with zealotry as well a myriad of IDE environments. For at least vi and emacs, all source files utilize a local variables block that is understood by both editors in order to encourage a project-defined convention with consistent indentation:

    /*
    * Local Variables:
    * mode: C
    * tab-width: 8
    * c-basic-offset: 4
    * indent-tabs-mode: t
    * End:
    * ex: shiftwidth=4 tabstop=8
    */

    With that comment block at the very end of all source files (whether they be C, C++, Tcl, Perl, Sh, SGML, etc), we do quite well in maintaining order and minimizing the indentation dispute. For the IDE environments, it at least gives them clear documentation on how to configure their IDE indentation preferences to match in every file. Maintaining a tabwidth/tabstop of 8 ensures consistent source display in most environments, including text printing and console display, leaving projects to simply define what offset/shiftwidth level they want for indentation. It can similarly still be tweaked for the projects that seem to insist on no tabs or want to match some IDE default religion.

    --
    Cheers!
    Sean
  10. Re:A standard tab length would be easier by peterpi · · Score: 5, Insightful
    And they make the fundamental misunderstanding in the very first sentence! Why is consistency desireable? Why should my text editor render code consistently with yours? We could be using a different font in a differerent point size at a different resolution. Is that important too? I have white text on a black background on one machine, black on white white for the other. If you specifically need some lines of text to be lined up with each other (consistency within the confines of the document), use space. If you just need it to be shunted over to express intent, use tab. That way we can both set tab to look exactly how we want it to.

    eg: (---> means 'tab', '.' means 'space')


    void foo ()
    {
    --->if (something)
    --->{
    --->--->/* I like to format my comments so that
    --->--->.* the stars make a vertical line,
    --->--->.* but I don't care how much you like to
    --->--->.* indent */
    --->--->bool something = SomeLongFunction() &&
    --->--->.................Another()
    --->}
    }


    This code satisfies everybody with a good text editor. If you like 8 spaces, set your editor so. If I like 2, 7 or 3.14 I can set mine. Pressing space n times annoys everybody who likes 2n, n/2 or any other number of spaces.

    That way they can get on with arguing over important issues like the placement of {

    ;)

  11. Uh... ok... by zizzo · · Score: 4, Funny

    I read the article and played his demo. I'm not excited by this at all for 2 reasons: it invents yet another model of tab spacing and it encourages use of tabs.

    Tabs just need to go away so we can get back to real debates, like CR vs. CR/LF vs. LF.