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!"
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." Get Linus to approve of it or something for good measure.
Speaking of tabs, something that I would absolutely love:
I want to be able to indent or unindent the opening statement for a given loop, be it int, sub, function, if, for or else, and have the entire section that it describes, including the braces, indent accordingly.
Anyone know of an editor that has this?
Umm Word has been doing this for year.
**Runs**
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.
I mean, the same could be said for, let's say, PageMaker. Or OpenOffice. Or a lot of text layout tools.
But code editors they are not.
We brough content folding and syntax highlighting to text editors. Now it's an appropriate time to bring them layout magic, I suppose.
THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
BTW: indents should be 2 spaces and code should be manually wrapped at 76chars, anything else is for failures!
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.
Whether or not this solves the problem (I don't think it does), I get real nervous when source code starts being perceived as a document that lends itself to proportional fonts. Maybe I haven't been in the latest and greatest IDEs lately and am missing something here, but source code seems to scream for canonical form, and proportional font is not that.
I think vim has a reasonable approach (do the research: shiftwidth, tabstops, softtabstop, etc.), I assume there are other approaches in emacs.
Start talking about proportional font source code documents, and now everyone's going to want to have styles, and all the confusing garbage that is word processing. As difficult as source code and programming is, it doesn't need to be more nuanced in word processing.
Tabs have been and should continue to be what they are. If you need to format code within the 8 spaces, then use a tab. Otherwise use a space. In no other way can we get source code that looks consistant across editors and platforms. Especially in neat languages like python. Attempts to redefine tab stops are misguided. And don't even get me started on the use of proportional fonts in programming editors. Heresy.
He's right that mandating "tabs must be N spaces" is stupid, though. Use tabs to indent blocks of code, use spaces for aligning code that isn't in blocks, and people should be able to set whatever tab size they want without ruining anything.Now, let's see if I can keep this from being mangled by Slashcode...
On preview: no, I can't. Well, imagine that the C in Class is directly under the i in int, and imagine that the a in arg2.is_valid() is directly under the a in arg1.
Of course, getting this right every time isn't easy when you're trying to think about your code and your editor has it's own ideas about indentation. I'd be very happy if anyone could tell me how to get Vim's autoindent to behave this way.
Then emacs will replace tabs with spaces. In the various programming language modes, tab indents to the right location (Which you can customize somewhere else.)
vim has a similar setting but I rather despise vim (I prefer nvi or old school vi when doing vi things.)
I'm trying to teach myself to set people on fire with my mind... Is it hot in here?
Wrong. A TAB represents 1-N spaces, depending on the current column, where N is the tab setting. I've never seen a TAB interpreted as a fixed number of spaces, and I've seen a lot of output devices in the 40 or so years I've been playing with computers. TABs move the output position to the next tab stop, not some fixed number of spaces.
Those who do study history are doomed to stand helplessly by while everyone else repeats it.
What a great social engineering trick - get 30% of Slashdot readers to locally execute untrusted code with local thought. Cracker, my hat is off to you!
Innovation at last!
- Bill
So, uh. What the fuck does VS have to do with anything?
I've never used it so I can't comment. So it has variable-width fonts and logical indenting and spacing? Good for them.
If it appears in anything _besides_ Visual Studio I'll be a happy camper.
THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
I can grudgingly accept the arguments of the web site mentioned in the summary, but I am not convinced their solution is the answer. Certainly it will only work if *all* text editors work that way. And that is not likely to ever happen.
Using 8 is idiotic. 2-4 spaces should be enough for anyone. This is why I always convert tabs to space anyways.
... will it run make?
8 of 13 people found this answer helpful. Did you?
If you play with the demonstration editor a bit, you can see that this has potential.
BUT, I think it would only be useful in editors with some syntactical idea of the code they're editing, like Netbeans/Eclipse/vim and so on. In the demo editor, for example, tabbing will properly indent code only if you put a brace on its own line. If you don't, you get this:
if (blah) {
foowayoverhere();
}
Because it indents the next code too far, treating it as a comment. This idea could be very useful to coders, but it's really not for normal documents and it should not be implemented in editors where the format of the file is not known or completely understood.
But for XML editing...
The "tabs vs spaces" debate is an all-or-nothing religious war/social problem disguised as a technical problem. There are merits to both sides, but the debate will never end because there is no satisfactory compromise between the two opposing factions. The "elastic tabs" method presented in TFA is a misguided attempt because it proposes a technical solution that does not appease either sect, and it may even generate a third "religion" in this holy war.
For those new to programming, I'll let you in on a dirty little secret: for any given language it is always possible to parse and reformat the code to ones liking (e.g. indent, astyle, etc); therefore, the tabs vs spaces debate is completely moot. If Sam likes spaces and Tom likes tabs, they can both have it their way when they're editing code. Manny (their boss) can even insert a check-in filter that indents the code to his preference, a random mixture of tabs and spaces, just to remind them that he's the one in charge. Experienced programmers realize this, so we don't take part in such debates.
In conclusion, if tabs vs spaces really matters to your project, just install a check-in filter and shut up already. Some of us have work to do.
Tab is short for Tabulate - make into a table. Source code is not a table.
If you want to represent data in a tabular form then use tab stops and the tab character to separate the data items such that when it is displayed the data items form columns.
Source code for most languages is not like that. It happens to be convenient to use the 'tab' key as if it were an 'indent' key and space can be saved on disk by representing a number of spaces by a single character, but the 'tabbies' are confused.
It happens that _some_ languages are 'tabular'. Assemblers, for the most part, are best represented in columnar form. Perhaps the tabbies are locked into the 1960s when programs were written on 'card punch forms' and a format card was used to set the tabstops for the punch girls, but the cards had _spaces_ on them as Hollerith intended, the tab key did _NOT_ punch a tab character into the card.
I do use the tab key as a means of stepping along a number of spaces but the resulting files has exactly the number of space characters that are necessary and no tab characters at all.
The problem is depending on what source control system you are using you may get screwed over by diffs looking really bad depending on how it thinks of whitespace.
Otherwise I agree with you, and personally I would always opt for a version control system that would let people reformat code whitespace to their liking.
"There is more worth loving than we have strength to love." - Brian Jay Stanley
However, this type of formatting has been around for a while, in better language-sensitive editors, where you can adjust for formatting for the various coding contexts.
A better compromise would be to read any given code file for the given language, sense the coding style of the original document and interpret and display it on the editing widget in the manner you think the author wanted. Preserve the original document internally as a document tree and at save time, either save in exactly the same coding style as the original, or in the style the user wants. This would be similar to XML DOM readers that preserve an exact model of the original document in memory. And it is displayed according to its semantic meaning, not a tab or space count.
This would respect the coding style of the original author, while giving options to the user of the editor. A much better compromise, I think.
NEVER use tabs in code - or if you do, use an editor like jEdit that can automatically change them to spaces.
Or when you edit code and just have to change someone else's layout, do a find-replace on tabs with however number of spaces you want instead?
So, um, *what* better editor? jEdit doesn't seem to have features that vim or emacs lack, which is good, but it doesn't seem to have a console-only version, which makes it entirely useless to me and anyone else who programs on a remote machine over ssh. You're just insulting people without offering any reasonable alternative, and proving that you are nothing but a rabid fanboy. While you froth at the mouth, I'll be over here, doing some programming in an editor that will actually run on the machines I work with.
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.
Holy-crap! Now I remember why I hated VI in my undergrad. days (20 years ago, but it seems nothing's changed). Lemme get this straight: "%" goes to the closing brace, "=" auto-indents, "==" auto-indents the current line, "" indents right, etc? Oh, and if I put "set sw=2" in my .vimrc file I get two-space indents when I press the Tab key? Of course! How obvious.
These days, only an overly-smug uber-nerd would use something so pointlessly obtuse.
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:
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
Doesn't solve the problem at all. While his idea of lining up code that belongs together, e.g. code in an if-statement, is good, it doesn't address the fundamental problem of whether tabs or spaces should be used and how many characters/spaces should a tab/space use. One has to start indenting code before one can line up the rest of the code, so how does one start?
"Money is the barometer of a society's virtue." - Ayn Rand Atlas Shrugged
Holy-crap! Now I remember why I hated VI in my undergrad. days (20 years ago, but it seems nothing's changed). Lemme get this straight: "%" goes to the closing brace, "=" auto-indents, "==" auto-indents the current line, "" indents right, etc? Oh, and if I put "set sw=2" in my .vimrc file I get two-space indents when I press the Tab key? Of course! How obvious.
That's like complaining heavy-duty industrial machinery isn't user friendly. If you need the power, something simpler and easier to use won't cut it.
These days, only an overly-smug uber-nerd would use something so pointlessly obtuse.
Yeah, and only a smug bastard would drive a dump-truck instead of a much easier to drive small car.
Brief
I don't mind tabs. I don't mind spaces.
But God help you if you mix them together in the same program.
I've met editors that put four spaces for the first indent, then a tab for the second (removing the previous four spaces in the process). It was fine when you viewed the code in that particular editor, but open the same code in another editor with different tab stops, and it became practically unreadable. If they'd stuck with just tabs or just spaces it would have been fine, but nooooo.... some bright spark had to mix 'em together. Grrrrrrr.
(For what it's worth, the editor in question was LSE, on a VMS system. I don't know to this day whether that was the default setting or a setup made by someone at the company, but it caused a nightmare when we ported the system to Windows)
(Spudley Strikes Again!)
I understand your point, but why do you consider "easy to use" and "powerful" to be incompatible?
This isn't the days of the PDP-11 -- there's more than enough cycles and megabytes to spare for running a nice, friendly text editor with a *sane* set of keybindings, *helpful* help text (none of the traditional *nix man nonsense, e.g., "the yank keystroke yanks text from the yank buffer") and easy customization (note: putting "SET SW=2" (crap, it's probably case-sensitive, so it should be "set sw=2", or is it "set sw = 2" ala bash scripting) is *not* easy customization, especially since that hack is probably only documented at the bottom of some completely inaccessible man page, if at all).
By the way, your analogy if flawed. If text editors are to be compared to heavy-duty industrial machinery, VI is a steam shovel. *Wood fired*.
Actually, this does sound superior to me over the first two (especially for something like Python where indentation is meaningful).
But if you thought we had holy wars now, just imagine the nightmare that a third option will introduce...
> I understand your point, but why do you consider "easy to use" and "powerful" to be incompatible?
What's not "easy to use" about pressing one key to perform a complex operation. I'm no vi fan, but that sounds easy to me.
(emacs is M-x indent-region, or whatever you've bound that to.)
My other car is first.
One of the key things about vi(m)'s keybindings and commands is that they are extremely concise. I defy you to come up with a sane UI which allows the user to say "capitalize all a's, z's and t's that start words but are not followed by a digit, in the following thirteen lines".
Please note that I am not saying that it is easy to learn how to do that.
Do you know how many times I've deleted one goddamn space only to have the whole line jump four or even EIGHT spaces over too far? Morons...
Do you know how many times I've tried to delete one goddamn tab-indentation only to find that some moron used a billion space characters to indent, making me hit backspace over and over where a single tap should have sufficed?
Fucktards.
As far as I've come into contact with developers there never has been the slightest doupt what the right thing is. Tabs where introduced as the solution to this very problem. The only problem is that ancient vi and emacs aparently can't deal with them properly. Or their users sometimes are to lazy to set them up properly. The big problem is when experienced professionals follow suit with some blockheads and a few years later themselves insist on everybody using spaces at any time.
Why should everybody degrade the sourcecode because some dick on the team insists on using a 25 year old editor? Why should we be forced to use spaces in interpreted webapp languages because some webserver is to crappy to deal with tabs in the right manner? Unless there's some exotic situation - which I can't think of right now - that requires spaces to be used the stored source should be tabs. Then everyone can decide by himself how wide his indents are without bugging anybody else with his habbits. And if you're to fucking lazy to set up your vi or emacs properly to deal with the problem (either by back and forth conversion of tabs2spaces/spaces2tabs or by altering the display of code) and thus insist on the team following your whim you're nothing but a fucking assh*le. Get with the 3 millenium allready and get yourself a proper editor. There are enough around allready.
This whole discussion reminds me of 5 Million mindless dumb and stubborn outlook idiots establishing fullquote bloat and degrading email to something worse than AOL chat for everybody else, just because their mailer is so crappy.
Bottom line: The solution linked is a solution to a problem that doesn't exist because in a professional enviroment everyone can decide for themselves how their code is displayed, how large tabs are and if they're automatically converted into spaces if I want to use edlin.
P.S.: In the recent years, so I've heard, we even got a new problem popping up: People mixing spaces and tabs in the same sourcefile. Now there's a bunch that deserves to be shot at sight.
My 2 cents.
We suffer more in our imagination than in reality. - Seneca
I don't know if this fits the bill, but KATE (KDE Advanced Text Editor) will indent blocks. Actually, it's the embedded editor in the KDE suite (for which KATE is the front end); I use the simpler KWrite and it does the same.
You can highlight a group of lines, and then indent or outdent using Tab or Shift-Tab.
If you want to indent an entire programming structure (such as a if-else structure) without having to specify the start and end of the block, you can use KATE's code-folding feature. It recognizes about sixty types of programming/markup languages based on the filename, and maps out the program structure in the margin (if you turn the feature on). For example, it marks the lines starting with "if {" and ending with "}" as a unit. You can collapse the unit into a single line, much like the outline feature of some editors, and you can highlight and indent the line as described above.
If it seems too protracted, you can always assign the operation to some macro key.
404555974007725459910684486621289147856453481154 in hex is "You sank my Battleship?"
[GPG key in journal]
Correct. By convention, almost all character editors make tab stops by default to be every 8 characters. Therefore any indenting in your code should automatically use tab stops and then use spaces to fill in the white space that doesn't lie on a 8-character boundary. This is what I meant. Thus the whole idea of fudging with the tab stops and using code formatters to replace tabs with spaces is a poor idea, as you imply.
Mmm, I don't think you can reformat brainfuck at will.
Were that I say, pancakes?
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.
The idea is neat, but it does not work so well in practice. He argues tabs have a single semantic meaning, but they'd actually have at least two distinct meanings:
Problem is: it's not always that easy to guess which behavior is the desired without either forcing the programmer to adhere to some new rules involving extra whitespace, or dropping the desired indenting completely.
For instance, the following examples don't work on his editor: (there's a "<TAB>" in there because I couldn't manage to make more than one consecutive space appear in that place)
Dude, get the net. Spaces already won.
I recall somebody here mentioning once that he worked at a place where CVS was setup to automaticly run indent on checkin and checkout. This seemed ideal to me--each coder would get to work in their own preferred style. Then I realized the problems it would cause with certain things. In most of my code, when I return an integer error, I use a macro that munges in a number for the file, a semantic error code (e.g., file not found) and--here's the problem--the __LINE__ directive. The beauty of this system is that since all the integers are compile-time constants, I get a lot of information in my error codes for no more runtime expense than returning something less informative (e.g., -1, or a simple EFOOBAR define).
The downside would be that if such errors were generated by sources compiled by different checkouts, with different styles, then reported errors won't match up on the same __LINE__. This could be resolved by eliminating the __LINE__ from the macro, but then you'd have to come up with a unique ID for each error, manually. That's tedious, miserable work. We could chose to have a single style for *compiling* the source as opposed to editing, but then you are right back to the same problem: there can be only one compiling/debugging style.
I guess, in lieu of __LINE__ I could use a manually enterred "random" number, and use a pre-processing stage to make sure that the number was unique--use the same number in the same file, and CPP fails, but this requires a hack to CPP.
FWIW, I use tabs becaues I figure that "presentation" is the editor's problem. I meant to tab in. If your editor is set to 8 spaces, that's your editor's problem, not mine. What's nasty is when stuff like MSVC converts tabs to spaces during copy-paste operations. My text has tabs in it. COPY-PASTE MY TEXT. DON'T CONVERT IT!!!
Of course then I end up with a "mixed" source code, and I can't tell what's happened unless I actually cursor back. Now, I know all you space guys are saying that if I just used 4 spaces I'd be fine, but then if my source is loaded by somebody who preferrs 2 spaces, or 8 spaces, they are SOL. They are slaved to my editor preference, and that's plainly wrong. In the long run, tabs are the only workable way to solve that problem, because they are, in a sense, "source" whereas spaces are the result you get when the text is "compiled" by the editor.
For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
If you use a revision control system, you'll tend to find yourself pursued by mobs of programmers (with scythes, pitchforks and burning torches) for mucking up their diffs.
"It doesn't cost enough, and it makes too much sense."
Yeah, except in the printing industry, where fixed-width fonts are nearly unknown. If you open random printed books, you'll find indents that range from 2 to 6 ens, depending entirely on the whims of the publisher.
The computer industry is a bit weird in its use of fixed-width fonts, which publishers usually find unaesthetic, but which are very useful to us computer geeks. But we do have word processor software that also default to variable-width fonts and indent by distance rather than chars. And CSS lets you define indentation by points or cm or other distance measures.
We should probably face a future in which most software also uses variable-width fonts, and the debate over how many characters to indent will be baffling to most users, because it sounds so nonsensical.
Those who do study history are doomed to stand helplessly by while everyone else repeats it.
"herefore any indenting in your code should automatically use tab stops and then use spaces to fill in the white space that doesn't lie on a 8-character boundary"
...will always align properly, no matter how width your tab stop is.
Utterly false!
I defy you to find probes of such an abomination!
Any sensible text editor (and to this point almost *all* text editors seem to be sensible enough) won't use spaces on a tab chain *ever*. A tab means "go to the next tab-stop" and only that. So if tab stops are every 8 chars and you are at column #23 a tab won't add a space, but will move you to column #24. If you are at column #25 it won't add 7 spaces, it just will move to column #32. If you change tab length, due to the fact that tabbing DOESN'T ADD SPACES, your editor will do the correct thing (where spaces added, your editor simply wouldn't know what to do, since it can't know it previous spaces were tab-paddind added or hand-added): it'll just go to "the next tab stop", wherever it currently is (and, by the way, that's the whole problem with spaces vs. tabs: the "inner tabbing", because changing the tab width will "jump" some inner tab stops from one point to the previous/next. All-lefty tabs are never a problem, only inner tabs are, and they can be resolved by using lefty tabs and inner spaces).
So...
(tab)function()
(tab)(tab)sentence(tab)//here a comment
(tab)(tab)longsentece(tab)//another comment
will deal to problems.
But...
(tab)function()
(tab)(tab)sentence()//here a comment
(tab)(tab)longsentece()//another comment
is 1.
Before veiwing any text documents, editors should have a optional transformation on startup, ripping away anything that doesn't conform to a users preference. For example, on c source files, the editor could run the text through a source formatter, presenting it to the user exactly the way he/she likes it to be set.
Then, who cares how things really are, we have our preference automatically assured!
This could perhaps be extended to changing between different spellings, I.e. Americanish => English.
Giving IE users a taste of their own medicine since 2005 - http://pods.-is-a-geek.net/
Think again. Of course you have to enforce a consistant environment for releases; but then you are back to having "one indent to rule them all". I guess you could say that's an incentive for developers to not produce bugs, because if they produce a bug they have to debug it with the release settings, and if they don't like those settings it's more of a hassle. Generally though, we don't want to hassle people.
For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
> Bottom line: The solution linked is a solution to a problem that doesn't exist because in a professional enviroment everyone can decide for themselves how their code is displayed, how large tabs are and if they're automatically converted into spaces if I want to use edlin.
Really? In almost all professional environments I've known, such things as this are included in the coding standards for the company. IIRC, the width of an indentation has never been the same at any two companies...I always use VIM, and have it replace my tabs with spaces, so it's never been a problem - for me or anyone else (who's following the standards).
Max.
At a company I worked for, the convention was to have "whitespace only" commits, and use those for fixing indentation problems (this was usually done by the QA guys). As for mucking up diffs, depending on the environment, it's not too difficult to get a whitespace-insensitive diff these days. (This is what was done at the aforementioned company.)
http://outcampaign.org/
That's why you want a good text editor. XCode is smart enough to backspace to the previous indent, deleting as many spaces as needed. I don't know about other text editors, I've tryed a bunch of them and always go back to XCode.
By the way anyone knows something better than XCode to edit Jam files ?
The wonderfully lean and functional editor ConText uses "smart tabs" - the relevant option is active by default.
Note two things:
- it works like Word (i.e. with tabstops defined at certain positions, not with tabs defined as expanding to a certain number of spaces)
- only fixed-width-fonts are available (which is good, since it's a programmer's editor)
Some people (or editors) think that tab = a certain number of spaces (which varies)
Some people (or editors) think that tab = skip to the next tab stop (which are spaced every X characters, and X varies).
So we have two issues to address - 1. Does Tab mean a certain number of spaces, or does tab mean to skip to a tab stop? 2. What is the value of X, (which may mean the number of spaces or distance between tab stops, depending on the answer to question 1.)?
Once the editor's managing the tabs cleverly like that, I start to want crazy things like automatic wrapping in comments that respect the comment syntax. Imagine if the comment in ETNotepad's example was considered to be one long string of text and wrapped automatically to however many lines are necessary to avoid the comment running off the screen. This could also be extended to code if people are happy to make some consistent rules about how they wrap. I have some rules of thumb for line-wrapping which I think could be expressed in code, but I've seen some developers that just seem to make it up as they go along.
The good thing about the web, is that 6 year old fuel is just as good as today's, and sometimes it even matures with age...
Here is jwz's not so recent, but totally relevant take on the issue: tabs-vs-spacesThree levels of indentation ought to be enough for anyone.
--Linus Torvalds
IF has THEN ELSE and ENDIF;
SUB has END;
FOR has TO DO and NEXT...
braces are not only {} () []
It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048
Use an editor that increases and decreases indents then - like jEdit.
Richard Steven Hack - This sig is TOO GODDAMN SHORT TO DO ANYTHING USEFUL WITH! MORONS!
The problem comes from other people adhering rigourously to other sets of standards, each camp being (consistantly) inconsistant with the other set of standards.
You've done a good job of defining the problem: you haven't solved it yet. People are the problem. The people who mix standards are going to be a problem in any religious camp: shooting them is a good first start to improving the programming world.
It's not too tough once you learn the basics of substitution and ranges.
--
Promoting critical thinking since 1994.
According to his development blog, the author is working on a solution to some of the issues raised by this story.
You can see the blog and comment here and subscibe to the RSS feed here
Heh. I knew that. What I wanted was, rather, that the parent poster show me how that would be doable with "sane" key-bindings and "sane" UI.
In my first job out of college, no one ever argued about tabs vs. spaces because we all just stuck with Visual Studio's default settings.
Personally, I think code intenting is so obvious that I don't understand why we're still arguing about style. Just give me an IDE that indents automatically! I'd rather spend my time getting used to it then counting spaces.
No, I will not work for your startup
I want to see all the information that the author of the code was trying to communicate to me. This includes the positioning of text.
Which side of the argument are you coming down on then? Sometimes in my code I'm trying to communicate, "this should be indented to the fifth tab stop," and sometimes I'm trying to communicate, "this number should be over three spaces so the rightmost columns line up." So I have to use both whitespace types in different places.
I suppose the way to convey author presentation is to have him encode his editor settings in the source file. Somebody else here posted a de-facto standard for doing so. Anybody in either "camp" wishing the other one away isn't actually making any progress.
My God, it's Full of Source!
OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
Also, your example of font size is irrelevant, since changing the size of a monospaced font is not a lossy operation.
How about syntax highlighting? I find sometimes that with highlighting a piece of code is easy to understand but with black-on-white text it's hard to tease out the logic or data structures.
So, isn't viewing code written in a highlighting editor in a non-highlighting editor or with other highlighting rules in effect a lossy operation? Do we start embedding highlighting rules in source code then?
My God, it's Full of Source!
OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
You have it completely backward. Tabs are meant to make things line up. That is their purpose in life.
Patrick Doyle
I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....