Visual Studio 2010 Forces Tab Indenting 390
An anonymous reader writes "For years, Microsoft has allowed Visual Studio users to define arbitrary tab widths, often to the dismay of those viewing the resultant code in other editors. With VS 2010, it appears that they have taken the next step of forcing tab width to be the same as the indent size in code. Two-space tabs anyone?"
This is news at any level how? (Score:5, Insightful)
This tab thing makes Slashdot front page and the following didnt? Windows 7 way hotter than Vista off the line, now more popular than all OS X versions [engadget.com]. Okay then...
How is this tab things news or interesting at all? Here is what Brittany Behrens a PM for the editor team said:
(bolding above mine for emphasis)
Gee, the team solicited comments, did some research and made a change that people wanted. Of course, any change will make somebody unhappy.
Brittany even volunteered to give folks a simple editor extension to make the settings different for those that want it. My assumption is that anyone using Visual Studio is a developer and capeable of using such an extension, or writing it themselves. It is not difficult.
-Foredecker
Re:This is news at any level how? (Score:4, Insightful)
This tab thing makes Slashdot front page and the following didnt?
Windows 7 way hotter than Vista off the line, now more popular than all OS X
versions
Of course id did; it's a developer tool so it immediately has street cred at /. ;->
Everything else that has nothing to do with coding or Linux is immediately a 3rd rate info byte unworthy of these hallowed pages
Re:This is news at any level how? (Score:5, Insightful)
This tab thing makes Slashdot front page and the following didnt?
Windows 7 way hotter than Vista off the line, now more popular than all OS X
versions
It's kdawson's shift. He'll never post any article that's even mildly favorable of anything Microsoft related. However, if you can find a story that says some kid in Sweden doesn't like the Windows 7 box-colors, you've got yourself a kdawson front-pager! :)
Re:Why put tabs in code anyway? (Score:5, Insightful)
They're a meta character, and the meaning can be changed later.
* If I'm hitting the tab key and it's inserting X spaces, and I hit the key once too many times, I have to hit delete X times instead of just once.
* If the code is reused in a new environment where everyone wants their indentation levels at 4 spaces instead of 2 or 3 or 8, you have to reformat a lot of code manually. If tabs are used, remap the sizing of the tab character and you're done.
* The tab character itself has some semantic meaning - indent. The space is a word and symbol separator. Use an indentation character when you want to indicate indentation.
Re:Why put tabs in code anyway? (Score:3, Insightful)
I find the use of spaces irritating and stupid, to be equally blunt. I mean, the tab is a character that exists _specifically_ for aligning text. It behaves predictably across editors and allows easy changing of width for various programmers. You never have to worry about half indents choking the editor. Why replace tabs with spaces? So you can hit the space bar a thousand times whenever you need to edit something outside a programming editor? So you can't change indent size without some obscene editor voodoo that may change the spaces and corrupt your diff history? But I doubt I'll ever understand... Most of the "benefits" I see people listing for using spaces I consider either more true for tabs, or disadvantages.
Re:Why put tabs in code anyway? (Score:5, Insightful)
The biggest benefit to tabs (especially if you code in a corporate environment) is that people can view the code based on *their* preferred indentation / spacing e,.g. I may like my tabs to be 2 spaces, another developer may prefer 3 or 4 spaces.
By setting up their IDE / editor to their preferred tab width, the code indents to the way they like it.
By forcing all your tabs to be spaces, anyone else viewing the code will be forced to view / edit it in your indentation.
Re:Why put tabs in code anyway? (Score:4, Insightful)
Re:This is news at any level how? (Score:4, Insightful)
No.
They solicited input from each other and in a blog post that generated a handful of responses. They did this to eliminate "a class of bugs" in the new editor that was triggered by setting the two numbers to different values. Which means they had a bunch of bugs (probably due to confusion between the two settings in the code) and someone had the brilliant idea that the bugs will go away if they just crippled the editor in such a way that the bugs will never be triggered. They solicited input, very quietly, and did it. This also means that the workaround they offer (writing a fucking extension, for fucking crying out loud - what is this, emacs?) will trigger all those bugs because they didn't fix them.
Idiots.
Re:Why put tabs in code anyway? (Score:5, Insightful)
So, for all those tab fans, what is it about tabs that you find useful?
So there you go. In addition to just being more manageable and flexible, using tabs over spaces will help ensure the future existence of the human species on this planet.
Okay, so while the last point was in jest (mostly ;), I stand by the first four. Honestly, I've yet to see any pro-spaces people give any substantial reasons (when applied to modern computers and development tools) that spaces work better than tabs.
So, for all those space fans, what is it about spaces that you find useful?
Re:Why put tabs in code anyway? (Score:2, Insightful)
If you use Tab characters, everybody on your team can pick whatever tab level they prefer. In short, everybody's happy.
If you use Space characters, and you prefer 4 spaces but someone else prefers 2, well, then they're fucked. (Or you're fucked. Somebody's going to be unhappy.)
Frankly, from a logical perspective, I've never figured out what benefit spaces have over tabs... my guess is that it's related to, "I learned programming in 1976 and damned if I'm going to change my extremely ancient and obsolete habits for you young un's. Also, get off my lawn!!"
What's that old saw? (Score:4, Insightful)
Re:Why put tabs in code anyway? (Score:3, Insightful)
Re:Why put tabs in code anyway? (Score:3, Insightful)
They're a meta character, and the meaning can be changed later.
* If I'm hitting the tab key and it's inserting X spaces, and I hit the key once too many times, I have to hit delete X times instead of just once.
Or press shift-tab or undo...
* If the code is reused in a new environment where everyone wants their indentation levels at 4 spaces instead of 2 or 3 or 8, you have to reformat a lot of code manually. If tabs are used, remap the sizing of the tab character and you're done.
I don't think it's really all that hard to automate the process of changing the indent spacing. In my experience, a bigger problem is changing other formatting conventions, such as where to put the line breaks.
* The tab character itself has some semantic meaning - indent. The space is a word and symbol separator. Use an indentation character when you want to indicate indentation.
While I see some value in what you're saying here, I'm doubtful that giving an invisible character semantic meaning is wise. It means you can't tell easily the difference between valid and invalid code. (Yes, I really hate makefile syntax!)
I also note that your latter two points only apply if the tab size is also the indent size.
Re:Why put tabs in code anyway? (Score:5, Insightful)
I find the use of spaces irritating and stupid, to be equally blunt. I mean, the tab is a character that exists _specifically_ for aligning text. It behaves predictably across editors [...]
Not in my experience it doesn't!
You never have to worry about half indents choking the editor.
I don't understand what you mean by this.
Why replace tabs with spaces? So you can hit the space bar a thousand times whenever you need to edit something outside a programming editor?
Ironically, one of the reasons I prefer to use spaces is so that the code is readable when I do want to edit (or view) something outside of the programming editor. Code with tabs in it is usually completely messed up.
Ah, well, it'd be a funny old world if we were all the same!
Re:Why put tabs in code anyway? (Score:5, Insightful)
I know it's bad form to reply to yourself, but really Slashdot? THAT is how you render an HTML ordered list? What blind, drunk monkey on an acid trip designed that stylesheet?
Of course the icing on the cake is that in the preview it was properly rendered as an ordered numeric list. WTF, Taco?
Oh, look at the name of the CSS files responsible: idlecore-tidied.css. Makes sense now I suppose. Anything to do with idle.slashdot is already horribly broken.
Re:Why put tabs in code anyway? (Score:3, Insightful)
That's a valid point, although I'm not sure how you avoid a mixture of tabs and spaces, which would make the code look completely wrong (instead of just a bit wrong!) for everybody else.
Re:Why put tabs in code anyway? (Score:4, Insightful)
Don't get me started on makefiles. An syntactically significant invisible character? Dumbest idea ever.
Re:Why put tabs in code anyway? (Score:3, Insightful)
It behaves predictably across editors and allows easy changing of width for various programmers.
I'm amazed that you can utter this with a straight face. "behaves predictably" and "allows easy changing of width" are pretty much diametrically opposed concepts, at least if you actually share your code with any other human being. If tab-width were somehow a universally self-describing attribute in text files, then this could fly. But without it, we're left in a place where others viewing your code open the file (or heaven forbid, use cat/more/less!) and then feel fscked.
I'll also observe that a number of popular editors don't even have clean per-project (or per-file) concepts of tab-width setting and such settings are often clunky in the best of those that do.
The only way to maintain sanity (Score:2, Insightful)
in cross-platform project is to force everyone to use spaces only. ;-)
The shit that happens to code with tabs that get edited on unix and windows and different editors make the text to travel towards the right side of screen at exponentially increasing speeds.
Add some retarded editors and direct copying of sources between unix and windows without going through source control system that converts line endings and you will also have empty lines being added as well.
The end result is 1/100 ratio between code and whitespace.
Hello from the trenches
Re:Best argument for using spaces (Score:4, Insightful)
And if you prefer to look at 2 or 4 spaces per tab, you're hosed. Tabs-only is best. Then each person can set the level of indent they want to see. As long as you don't mix spaces and tabs, you're fine.
Comment removed (Score:5, Insightful)
Re:Foredecker is learning... (Score:4, Insightful)
Re:Why put tabs in code anyway? (Score:2, Insightful)
How hard is it to find an editor that will handle TABS nicely?
It's not just about editors, but about terminal windows as well. Just such a simple command as "svn diff file.c | more" will indent at 8 stop tabs, causing unreadable wrapping. The problem is everything from Terminal.app (or gnome-terminal or whatever you use) to 'more', to diff vewiers, web svn tree browsers, trac, post-commit email, etc, has to be made aware of non-8 stop tabs and keep your individual preference. This is turn adds a need for login (or navigation options) - and just adds bloat and complexity for something that has a very simple solution: use spaces.
Re:How is newline invisible (Score:3, Insightful)
I think the issue is more that tab and space are visually indistinguishable.
A good guideline is that you should be able to glean all the semantically meaningful data from the source code even on a hard-copy. I can certainly see a newline in hard-copy (although I can't tell whether it's \n, \r\n, \r or whatever). Similarly, I can see tabs in hard-copy, but I can't tell them apart from spaces, so in that sense it's wrong for them to be any more semantically meaningful.
Re:Why put tabs in code anyway? (Score:3, Insightful)
Dude, the editor takes care of that for you. Why micromanage spaces and alignment when that's what computers are good for? There's a reason things like ReSharper exist. I never ever use tabs (option is set to insert spaces instead), and I've never had to deal with any of these issues the "tabs not spaces" crowed insist exist if you use spaces.
So, what you're saying is, as long as you're using the right editor, it'll take care of these things for you, it's only a problem for people who pull it up in a different editor that doesn't do the same micromanagement yours does. I point this out not because you're in any way wrong, but for some reason fans of using spaces instead of tabs often complain that the way different editors deal with tabs is a problem, while acting as if this isn't a problem in the other direction. Personally, I find the behavior of tabs across editors to be far more consistent than the way spaces are treated, because some editors do exactly as your does (and should), but more do not, or they do some random subset of all the nice things they ought to do, like making a single delete drop a whole indent level, or just a space, or how the arrow moves through them, e.g go one space? one indent level? go directly to the first non-space? Will it even let me arrow back beyond the first non-space character? Sometimes yes, sometimes no, sometimes a space at a time, sometimes an indent level at a time, etc. There's no good argument to be made in favor of either spaces or tabs in which one cites inconsistent editor behavior, it cuts both ways, but space-indenters always seem to cite these inconsistencies as if it somehow only affects tabs and not spaces.
Re:This is news at any level how? (Score:5, Insightful)
Re:Why put tabs in code anyway? (Score:3, Insightful)
From a purely pragmatic perspective, my main problem is simply that I've found it impractical to use tabs consistently. Some lines always wind up having spaces in them instead, and since you can't see the difference, you can't easily fix it.
(Also I don't like seeing eight-character indentation when I need to view the file from the command line or in notepad, but that's a minor point.)
A Tab is 8 spaces nothing more, nothing less (Score:3, Insightful)
It is really unfortunate the IDE's let people change the tab setting and even more unfortunate that IDE's like Eclipse and IntellJ come with it incorrectly set to 4 spaces. This has the effect of totally buggering the code when viewed in any context other than one with the same settings. Printers and most code viewers use an 8 character tab stop.
Yes things work fine if you forbid mixing tabs and spaces in indent but, in my experience this does not work in practice.
Re:The only way to maintain sanity (Score:3, Insightful)
Never had a problem with tabs until spaces get in the mix, and then different conventions completely screw up your code.
In other words, everything is nice and neat with tabs until some asshole starts putting spaces into the code for indentation/alignment :-)
Re:Most editors do this... (Score:2, Insightful)
It also makes lining up parameters on multiple lines look like complete and utter ass because that usually requires a combination of tabs and spaces.
Re:This is news at any level how? (Score:3, Insightful)
Re:TABs are for TABles! (Score:3, Insightful)
I'd disagree there, but to each his own.
Erm, it is still there, just as if it were a space? And some IDEs may even still keep your code lined up and not indent it further than its neighbours, or else it'll behave the same as spaces.
What happens to the spaces in that situation? Same thing.
Which spaces? Editors will have one of two behaviours: 1) be "intelligent" and keep the indenting at the same level (so it'll tab it the same depth) or 2) be "dumb" and drop it to the start of the line, at which point I tab it back to place with a couple of key strokes.
How do you know that the indentation contains only spaces? ;)
Yes, yes, no. In the first two cases it works sometimes and not others, depending on whether it was done with tabs or spaces. The advantage if it was done with tabs is that it'll work no matter my tab width, where as spaces are going to be wrong for someone who uses 8 where people use 4 or whatever.
No, we have one character that means "insert a single character space, such as might be found between two words" and one character that means "move the text to a fixed position according to the tab stop/width". Why overload one character when you can differentiate with two? ;)
How can you be sure that they contain the right number of spaces? Every time I've worked with space indenting then I've ended up realising that one method block was indented by 5 spaces instead of 4 only at the point where I paste some code that is indented 4 spaces. Tabs, on the other hand, are generally quite obviously wrong because they're a full layer of indenting out of step.
By configuring them? PDF shouldn't make a difference, since PDFs are about identical presentation. OCR and document editors are customisable, but even if they aren't then half of the point of tabs is that they can fit whatever width.
If your OCR reads 2x8char tabs instead of 4x4char then you've got half the indentation when you read it and it needs fixing, but it is just as likely to read 10/11/13 instead of 12 or whatever when using spaces. That's just called sanitising your inputs. Besides, how frequently do most people OCR their source code?
If people really want to use spaces then that's fine, I just find it interesting that so many of the reasons for spaces being better can apply equally well to tabs being better!