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!"
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.
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.
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:
//Every line starts with tabs: //Tab can be any length, whole line moves in or out
int foo ()
{
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
);
return -1;
} else {
return rand();
}
}