Posted
by
kdawson
on Sunday January 24, 2010 @11:26PM
from the one-man's-readable dept.

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

How is this tab things news or interesting at all? Here is what
Brittany Behrens a PM for the editor team said:

Hi Brien,

Thank you for logging this issue. Before making this change we
solicited feedback on the decision to combine Tab Size and Indent Size from
a wide variety of sources, including public blog posts and forum
threads, and found that the vast majority of user
feedback was in favor of combining the two. If its seriously
impacting your code to have Tab Size always equal Indent Size,
it is possible to write a short editor extension to
override the Tools->Options dialog and set the two options separately.
If thats something youd be interested in, please let me know and Ill see
about posting sample code for how to do this.

Im resolving this issue as By Design because we intentionally combined
these options for VS 2010, but please feel free to post again here if you
have any further questions or comments and well be happy to help.

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.

Windows 7 way hotter than Vista off the line, now more popular than all OS Xversions

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;->

Windows 7 way hotter than Vista off the line, now more popular than all OS Xversions

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!:)

That's a very unfair characterisation; there's much more to kdawson than just Microsoft bashing. Specifically, if you have some shitty snake oil vapourware that you'd like to peddle by shilling an advert thinly disguised as an article, he's your guy.

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.

BTW - I wrote a script to change all the spaces used to indent php code for a popular cms to tabs
s/ {2,8}/\t/g; # replace anything from 2 to 8 spaces with a tab
Also joined long lines that had ridiculous double-indent for the second, 3rd, 4th, 20th lines,

Added a few other optimizations, like removing the stupid "xml-like" closing of entities in html files.

Did you read the blog post [msdn.com] where they solicited feedback? It had 9 comments in total. Among them was this comment from the author of the blog (4th comment):

I assure you we won't be changing that option [tab vs spaces] any time soon:-)

So they solicited comments on a blog that no one reads and immediately say they aren't planning to change anything when questioned. After saying they wouldn't be changing the option, no one complained. Wow, what due diligence.

Do they count all of us who bought computers with Windows 7 pre-installed and then deleted it? Sure people rushed to Windows 7 - it's been a while since anyone running a PC could buy it with an OS that wasn't total crap so they could all finally get the updates they wanted. Windows PCs tend to be cheaper than Macs. Saying they outsell Macs is like saying they sell more Ford Focus's than BMW's. A PC does what a Mac does for half the price. It just doesn't look as good, work quite as well, last as long, or of

Of course the tab thing made Slashdot front page. Some people here virtually LIVE in Visual Studio, and code indentation is a heavily entrenched basic function of coding that people get surprisingly fired up about. Even if this particular aspect of code indentation isn't going to effect people, it's just begging for a heated emacs level discussion.

Your article, on the other hand, basically confirms that people like Windows 7 more than Vista, and that Windows 7 continues the well known and understood tradition of Windows outselling OSX by a factor of 10 to 1. These are things we already knew. Also, the article you site isn't even the source of the information, but refers to a much better Ars Technica article, which itself gets the data from Net Applications. I wonder if you didn't link the Ars Technica [arstechnica.com] article directly because it claims that "Linux was the only operating system [in December] to show positive percentage growth in market share." Or maybe this one "When putting this into perspective across the whole year, though, we see that Windows was actually sliding steadily throughout 2009 (93.66 percent in January 2009), while both Mac OS (4.71 percent in January 2009) and Linux (0.90 percent in January 2009) have been gaining." Or maybe the fact that Windows XP continues to hold onto 2/3rds of the active Windows installbase.

Also, it might be nice to point out that you're work at Microsoft in the Windows org as a development manger. It would boost your credibility as a poster, and reduce potential conflicts of interest.

I'm sure that's it. It's not that Windows runs all the software that people actually use, or that it runs correctly on the computer they buy, or that devices they buy will work with it instead of requiring installation of special programs from God knows where that may or may not work depending on your kernel version, etc. There's plenty of shit on the Windows platform, but at least people who aren't programmers can get work done.

You can then retrieve the exact number of tabs the last editor to that block/line of code had in mind when they wrote it. This does add a bit of overhead, mind you, such as needing a pint of goat's blood every time you run the program.

Yeah, but it doesn't matter what the indent is as long as your consistent. Python 3 won't let you mix tabs and spaces so you won't run into issues. You will still run into issues with Python 2 (which I believe IronPython is still using) since Python always considers tabs to be 8 spaces regardless of what your editor is set to.

Just as well too! You wouldn't really want the compiler to react to code differently depending on what editor it was written in, and depending on what settings the particular editor

I personally like to use tabs, so when I open the file my editor represents the tabs as width as two spaces, while my colleague uses a four-spaces-for-tabs setting as he prefer that way.you can't do this using spaces.

when I open the file my editor represents the tabs as width as two spaces, while my colleague uses a four-spaces-for-tabs setting as he prefer that way.

And then comes another guy who uses three spaces to indent and your code is gone. Allowing each user to change arbitrarily the width of the TAB is a BAD idea.

The original use of the TAB key was to ease the creation of tables in typewriters. There was a set of mechanical stops, one for each column, and you could set or reset each stop. Pressing the TAB key moved the carriage to the next stop. Some electronic terminals, like the VT-100 for instance, kept this convention, allowing one to set or reset the TAB stop for each column. In modern computers this is not really necessary, since editing tables is often done in spreadsheets.

Setting the TAB width arbitrarily at fixed multiples of eight or any other number of columns really doesn't help much, since the indentation support of modern editors is much more powerful than that.

The only use of the TAB key for me is moving to the next widget in the GUI.

Herb Sutter once observed in relation to C++0x that when it comes to complex, interesting questions of language design, very few people are even vaguely qualified to comment, and when it comes to issues of whitespace every idiot on the planet has an opinion. And when those idiots get the chance, they'll post those issues as news on an aggregator of some sort (ok, that last part wasn't Herb Sutter).

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.

There are editors that don't let you define arbitrary tab widths? No, seriously -- I'm not sure I've ever seen an editor that didn't provide the option, generally along with the option to have the tab key insert spaces instead of tabs, thereby avoiding that issue and the inevitable problems that arise as tabs and spaces are mixed.

And if that doesn't work, there's this really newfangled tool called indent that you can use...

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 wh

I know this is Slashdot an' all but really? You've got to the point where you have to bitch about tabs settings in MS's development environment. Have MS not been squishing enough small companies or something equally evvvvvvil for you lately? Quick everyone, another example of MS being a horrible overlord, they've combined tabs and indent in Visual Studio!

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.

I would encourage anyone who would prefer VS return to two separate options to vote on this bug, as your feedback can certainly influence decisions about this issue in the future.

So, would the six Microsoft developers reading/. please go and place your votes?

Personally, I find it interesting that the change is about coalescing the "tab stops" and "indent characters" into a single setting and yet discussion has boiled down to a Tabs vs. Spaces debate. Oh that's right, nobody reads TFA around here.

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.

* 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.

* 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!)

Yes yes, Visual Studio 8 barfs when certain project-related files use "\n" line-endings, instead of "\r\n". GNU Make uses its own stupid tab-syntax, and I've never heard anyone praise that decision. However, most major compilers (including Microsoft's) don't care one bit about EOL-style. Every sane programming language allows "\0" or "\000" or "\x00" to represent nonprintables in string literals.

I can't tell if you're being serious or not, but if you look at precedent in developer tools, people do want

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.

Or you can intent with a single space and your code will be clear and easy to read instead of quickly rolling off the end of my 30" monitor. I should never have to scroll horizontally when reading code. Of course some dipshits think the entire program should be on one line.
Who uses a crappy editor that doesn't adjust formatting to match your preferences?
The tab character has the semantic meaning of jumping to a random spot in the middle of the page with the behavior being different in every app on every c

Or you can intent with a single space and your code will be clear and easy to read instead of quickly rolling off the end of my 30" monitor.

A single space is usually not enough indent to allow easy scanning of multiple nesting levels. Block-indentation has to be significantly different than intra-character indentation, or they start to blend too much (j and m are nearly half a space apart, depending on font face).

Nested loops and conditionals should be limited in complexity. If you have something 5-6 l

Sorry, there's probably a better phrase for what I'm trying to describe, and/. is mangling my attempt at ASCII art. Replace these underscores with spaces and you'll see the effect I'm going for. When L (and most characters in a fixed-pitch font) is the leading character in a line, it is visually as far-to-the-left as possible. However, some other characters (|ijf) will be centered, giving the appearance of being shifted slightly to the right. If the only indentation is a single space, the distinction between "real" indentation and leading whitespace inside the character's region is fairly small.

L_L__L___L____L____L____L____L____L__|

If you use more spaces for an indent level, even a dead, beaten horse could easily identify the nesting level.

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.

This is only true if your editor is being stupid. For example, TextMate has a "soft tabs" mode that inserts spaces, but the UI works exactly as if tabs are in use. The same convenience when editing, without the dagger-eyed looks from your collaborators.

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 edit

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.

What I hate most is cutting and pasting tabs. One program will treat it as a tab, another as x number of spaces, and another as y number of spaces. It's horrible. If you use spaces you know what you are getting.

Why would knowing the number of spaces ever be important when you are writing indentations in code? I mean, do you make comments with arrows that move horizontally and then point up or down to the beginning of the code they are referring to or something?

How hard is it to find an editor that will handle TABS nicely?If you are forced to use notepad then jeez, find a way to install scite or something small that works better.Dont force your self to use a crap editor that is NOT meant for code.

Seriously, thats a poor mans excuse, "because i have to use a shit editor" , get a better editor / viewer. There are 100s of em.

Sometimes you just want to view code without pulling it into your entire development environment. I use http-based subversion, and I am frequently going to URLs in my web browser to look at code snippets. And seriously, it doesn't take very many people working on a single codebase for tab consistency to start falling apart. All it takes is one person editing one file on a remote machine to screw the pooch.

I think its an old person new person thing. People who are used to programming with 80 chars being their monitor's limit are also used to the default tab size being like 5 spaces or so and they probably never figured out how to change that size and save it. New people who grew up with a monitor that manages more than 800 pixels horizontally and with an operating system that you can alt-tab with *should* prefer tabs, but it appears some people still hang on to old ideas, probably because some 40 year old or

No they shouldn't. Tab characters are nothing but an ancient and very primitive text compression scheme. They add zero value.

Tab characters have no defined meaning, are interpreted differently everywhere, usually can't be visually differentiated, break code WYSIWYG, mess up cursor movement, often mess up code alignment, sometimes mess up diff's, sometimes mess up file seeks, are the only ASCII character that requires a complex algorithm to display, interact badly with Unicode and are

Three shall be the number thou shalt indent, and the number of the indenting shall be three. Four shalt thou not indent, neither indent thou two, excepting that thou then proceedest on to three. Five is right out.

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.

Do you draw naked ladies in your code or something and insist on using the tab key for white space? Explain how if I like my tabs to be 2 spaces and I am sharing code with someone who likes 5 spaces, that we can get along unless we both use tabs and have our editor of choice configured to use our preferred number of spaces?

Tabs can be represented by as many "virtual" space characters in the editor as desired by the programmer, allowing them to work with the amount of indentation they prefer without forcing that representation as spaces in the sources. Plus it saves a lot of bytes for those that still save their source code on floppies.

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.

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.

It's still possible with spaces - writing a script that counts the number of spaces at the beginning of each line, divides by N, and multiplies the result by M is trivial in any scripting language. I suspect it would be a one-liner in Perl.

Meanwhile, using tabs to align anything but the beginning of line (i.e. comments) fails utterly, because there you have to rely on a particular width to line things up. But then also there are formatting styles for which you need such alignment even at the beginning of th

But you wouldn't use tabs for that. You would use tabs to indent to the current level, and then spaces for formatting. In the example you showed where everything is at the top level, there would be no tabs at all.

It's not about the seeing. It's about the number of key presses from the left edge of my screen.

If I arrow to the right four times, then I'm four levels deep.One...Two...Three...FourI prefer that toOne...Two...Three...ONE...One...Two...Three...TWO...One...Two...Three...THREE...One...Two...Three...FOUR

I don't have to backspace many times when I remove nested loops and they always line up properly (a personal thing that drives me nuts when two lines in the same scope don't line up) and it only needs one tap of a button to make it done. Hitting the space bar isn't a bad thing but it just feels inefficient when you have to repeat it so many times also most editors will allow you to highlight code blocks and use tab or shift-tab to increase/decrease white space which I'm not sure if they will do the same for you for spaces.

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.

And of course selecting text and using Tab/Shift-Tab to change indenting works just fine if you're not using tab characters. Why wouldn't they?

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 behavi

He forgot to use the code tag. Except his example using "..." to represent a section of whitespace just shows he's not only new around here, but to coding as well. Never tab after non-white space characters. In his example he stuck the "//" at the beginning of the line and was indenting after it.

So, for all those tab fans, what is it about tabs that you find useful?

I can have my indent be 2 spaces and you can have it be 8 spaces, all without changing the source code.

Files are not constantly being changed and updated in the source control system due to the number of spaces changing as different developers edit the code.

If I want to print out a section of code, I can modify the tab/space equivalency so that the lines easily fit on the page without wrapping.

Tabs provide a one-to-one relationship between the level of indentation and the number of characters used. This isn't usually a big deal, but in terms of parsing and editing I personally find this more elegant than using spaces (an inconsistent many-to-one relationship).

It saves electrons. One tab character generally fills the shoes of four space characters. That's a savings of 75%! Smaller storage and transmission requirements means fewer servers in the datacenter which means less heat created which means smaller refrigeration units which means less energy consumed which means fewer greenhouse gases emitted which means less global warming which means continued survival of the human species.

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?

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 hab

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.)

Bah, you'll get stuck on where to put curly braces after that, anyway. Or whether to have space between keywords and parentheses. Or whether to use parentheses with "return". Or whether to stick * and & to type name or to variable name in declarations. Possibilities are endless, and someone is going to be unhappy no matter what.

Frankly, from a logical perspective, I've never figured out what benefit spaces have over tabs...

Ability to aligning comments on several consequent lines, parameter names in a function declaration, arguments in a call... many things that are impossible with tabs.

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.)

So, for all those tab fans, what is it about tabs that you find useful?

When I want to dedent I can press del once, not four times.

I like my code when the indent size is about 4 space wide, my neighbor likes his code cramped at 2 spaces and some other weird people like it at 8 spaces. With tab and the editor settings we can all get what we want. Without generating a whole file modification changeset each time we decide to disagree on code spacing.

~15% in code file size reduction. I know, who cares, but still.. It feels cleaner.

The only real problem I have with tabs is when they get used other than for indenting, as a way of inserting three spaces because that was the distance to the next tab stop when the code was last touched. Then somebody inserts characters earlier in the line and bizarre things start happening over to the right. I think its that kind of thing which sometimes get tabs banned in some environments.

tabs can be displayed any way you like. if you indent with 4 spaces, the tab can be 4 spaces. if you indent with 9 spaces, the tab can be 9 spaces. everyone can configure their own editor the way they like it. if you use spaces, you're forcing your own indenting preference (which is probably stupid and ugly) on everyone else.

I'm with you. I *hate* tabs embedded in source files. They're nothing but trouble for all the reasons cited in TFA by those who want the setting separated.

I always set the "Insert spaces" option for tabs, and the first thing I do with any legacy code or other code I take over is "untabbify" the entire thing. I've worked to make it part of our coding standards that there be NO TABS in source files.

Tabs provide no benefit, and cause nothing but problems. You are correct: they irritating and utterly unnec