Slashdot Mirror


Visual Studio 2010 Forces Tab Indenting

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

61 of 390 comments (clear)

  1. This is news at any level how? by Foredecker · · 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. Okay then...

    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.

    Thanks for trying Visual Studio 2010 Beta 2 and sending your feedback!

    Brittany Behrens

    Program Manager, VS Platform - Editor

    (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

    --
    Jibe!
    1. Re:This is news at any level how? by j741 · · Score: 3, 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 ;->

      --
      - James
    2. Re:This is news at any level how? by black3d · · 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! :)

      --
      "The true measure of a person is how they act when they know they won't get caught." - DSRilk
    3. Re:This is news at any level how? by Wumpus · · 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.

    4. Re:This is news at any level how? by Col.+Klink+(retired) · · Score: 3, Informative

      Did you read the blog post 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.

      --

      -- Don't Tase me, bro!

    5. Re:This is news at any level how? by cgenman · · Score: 5, Informative

      This tab thing makes Slashdot front page and the following didn't?

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

    6. Re:This is news at any level how? by Rogerborg · · Score: 4, Insightful

      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.

      --
      If you were blocking sigs, you wouldn't have to read this.
    7. Re:This is news at any level how? by Waffle+Iron · · Score: 3, Informative

      0.90 to 1.02 isn't particularly impressive. 0.00 to 5.71 is.

      It's not all that impressive if you've already enlisted every single PC OEM as your personal towel boy.

    8. Re:This is news at any level how? by Iyonesco · · Score: 2, Interesting

      Well it doesn't matter that nobody commented because they don't actually listen to feedback anyway. Take the example of when they changed the file tab order in VS2005 so that new tabs were added on the right. This change caused all your open file tabs to be pushed along making it impossible to keep track of the location of your file tabs and resulting in users wasting considerable amounts of time looking for files. The person responsible for this was Sara Ford and as you can see from the comments on her blog the response was overwhelmingly negative:

      http://blogs.msdn.com/saraford/archive/2004/05/14/132065.aspx

      Despite all these negative comments both her and Microsoft failed to take any action and no changes were made in the VS2005 service pack or in VS2008. Microsoft simply do not care what users think and and while the may put up the pretence of taking user feedback they always just do whatever they think is best. Sara Ford is a classic example of this and despite all the negative comments on her blog she was totally unable to accept that the change was for the worse. What's most absurd about this situation is that Sara Ford has written a book called "Microsoft Visual Studio Tips: 251 Ways to Improve Your Productivity". Given the she herself is responsible for considerably reducing the productivity of Visual Studio users through her absurd interface design I suspect the only use for this book would be as toilet paper.

      Sara Ford is the personification of everything that is wrong with Microsoft today. When Windows 2000 came out I thought it was extremely good, offering the stability of NT and the software compatibility of 98 while running very fast on the hardware of the day. Since that time Sara Ford Syndrome has set in at Microsoft and the company has been over run with "soft skills" people who have these brilliant ideas to improve usability and in the process have rendered Microsoft's software completely unusable. The user interface changes Windows Vista/7 and Office 2007 have made using the software provably slower, are provably less consistent and are extremely wasteful of desktop space. I'd rather face torture than use Windows 7 or Office 2007 and many others feel the same way but despite the wave of negativity above these new user interface concepts Microsoft continue to push on regardless of their customers' opinions.

      This time however it looks like it's going to cost them since they've split their operating system market into two camps with the vast majority in the XP camp. They're suffering revenue declines since people don't want their newer software, they're losing market share to Apple and they were forced to practically give Windows 7 away with their pre-order discount program to try and generate some positive hype. While 14 year olds may be rushing to Windows 7 with it's cool transparent Windows frames the corporate market is staying well away and have clearly indicated they have no interest in the new software Microsoft is trying to force on the market through their monopoly. By refusing to sell the software customers want and trying to force them to use software they don't it looks like Microsoft's latest monopoly abuse may be what finally brings their monopoly to an end.

    9. Re:This is news at any level how? by siride · · Score: 2, Insightful

      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.

    10. Re:This is news at any level how? by maxume · · Score: 2, Informative

      You read it wrong, the only thing he left out was attribution, it isn't some big sekrit:

      https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=517188&wa=wsignin1.0

      --
      Nerd rage is the funniest rage.
  2. Tabs vs. Spaces by dziman · · Score: 5, Funny

    FIGHT!

    1. Re:Tabs vs. Spaces by osu-neko · · Score: 2, Funny

      Well, sure, if you're going to count raw numbers. There's like four or even eight spaces for every tab. :p

      --
      "Convictions are more dangerous enemies of truth than lies."
  3. Re:Best argument for using spaces by Sehnsucht · · Score: 2, Funny

    Anything else will always get screwed up by someone or some tool.

    Why are you repeating yourself?

  4. Re:Why put tabs in code anyway? by mgkimsal2 · · Score: 4, 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.

  5. Re:Why put tabs in code anyway? by Artraze · · 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.

  6. Re:Why put tabs in code anyway? by Dan+East · · Score: 2, Funny

    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.

    --
    Better known as 318230.
  7. Re:Why put tabs in code anyway? by yvajj · · 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.

  8. Re:Why put tabs in code anyway? by Nikker · · Score: 3, Insightful

    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.

    --
    A loop, by its nature, continues. If that didn't make sense, start reading this sentence again.
  9. Anyone, anyone? by Blakey+Rat · · Score: 5, Funny

    Ending sentence fragments with anyone, anyone? Does anyone like this convention, anyone? Can we just see it die horribly in flames, anyone?

  10. Re:Why put tabs in code anyway? by nmb3000 · · Score: 5, Insightful

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

    1. I can have my indent be 2 spaces and you can have it be 8 spaces, all without changing the source code.
    2. 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.
    3. 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.
    4. 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).
    5. 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?

    --
    "What do you despise? By this are you truly known." --Princess Irulan, Manual of Muad'Dib
    /)
  11. Re:Why put tabs in code anyway? by Blakey+Rat · · 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!!"

  12. What's that old saw? by liquiddark · · Score: 3, Insightful

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

  13. Re:Why put tabs in code anyway? by scdeimos · · Score: 2, Insightful

    You're confusing the tab key with the tab character. Do you expect to see arrow characters in your code when you use the arrow keys on your keyboard too?

  14. Re:Why put tabs in code anyway? by harryjohnston · · Score: 2, 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.

  15. Re:Visual Python by broken_chaos · · Score: 4, Funny

    import psychic

    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.

  16. Re:Why put tabs in code anyway? by harryjohnston · · Score: 4, 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!

  17. Re:Why put tabs in code anyway? by nmb3000 · · Score: 4, 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.

    --
    "What do you despise? By this are you truly known." --Princess Irulan, Manual of Muad'Dib
    /)
  18. Foredecker is learning... by symbolset · · Score: 2, Interesting

    Nice. I'm sure you'ld prefer to have something closer to the Windows core than this, but nice first post. If you're going to advocate it pays to have front billing.

    Now if you're going to drive off course from source code formatting to operating system adoption I can be forgiven for also going wide afield.

    How's that Window Mobile thing working out for you? Have they canned Roz Ho yet for the Danger debacle? Will she have to extrapeneur to a startup and bring back its corpse to prove her loyalty, or will she choose to spend more time with her family? Is September a solid date for WinMo7, and even then how do you expect phone vendors to personalize their experience and ship product for Christmas?

    Frankly I think two team reboots in the last year means you've got nuthin' for Christmas '10, and Christmas '11 is looking like less than even money. That's a long time for iSlates and Android tablets to be walking all over you. Of course I've got it being any good at 30:1 against.

    And what about Ballmer? Is an off 40% decade while Apple grew 7x and Google grew 4x not enough evidence that he's not getting it done? You would figure with all of the leverage and cash he's got he could do better if he was any good. Hell, I think I could do better than that even if I gave half the gross profits away to get some global love. With the money Ballmer has wasted on obvious dead ends over the last decade we could buy each Haitian refugee his own quake-proof palace.

    --
    Help stamp out iliturcy.
    1. Re:Foredecker is learning... by Toonol · · Score: 3, Insightful

      I think you may be verging on the insane.

  19. Re:Why put tabs in code anyway? by harryjohnston · · Score: 2, 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.

  20. Re:Why put tabs in code anyway? by harryjohnston · · Score: 3, Insightful

    Don't get me started on makefiles. An syntactically significant invisible character? Dumbest idea ever.

  21. Re:Why put tabs in code anyway? by Bill+Dog · · Score: 3, Funny

    You mean you can't see the brilliance of a preview mode that doesn't match what the real thing will look like? ;)

    --
    Attention zealots and haters: 00100 00100
  22. Re:Why put tabs in code anyway? by John+Whitley · · Score: 2, 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.

  23. Re:Why put tabs in code anyway? by weicco · · Score: 3, Informative

    I'm doubtful that giving an invisible character semantic meaning is wise

    (In the voice of dr. Farnsworth) Yes, yes. Let's all forget about those nasty invisible characters like \r \n and especially \0

    --
    You don't know what you don't know.
  24. The only way to maintain sanity by Technomancer · · 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 ;-)

    1. Re:The only way to maintain sanity by Bake · · Score: 2, 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 :-)

  25. Re:Why put tabs in code anyway? by poopdeville · · Score: 3, Informative

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

    No, it doesn't mean "indent". It means "tabulate". You shouldn't be using tab to indicate indentation. You should use tab align table columns -- i.e., to indicate tabulation.

    --
    After all, I am strangely colored.
  26. Re:Best argument for using spaces by nullchar · · Score: 3, 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.

  27. Re:Why put tabs in code anyway? by bit01 · · Score: 2, Interesting

    *should* prefer tabs,

    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 just a waste of time.

    If you want your code pretty printed with a certain indentation then run it through a pretty printer. Trying to get tabs to do this for you is a hack that should've died years ago.

    The first thing I usually do with any body of code I've been given to maintain is to remove all tabs and trailing spaces and if necessary run it through a pretty printer. I also configure my editor to not to insert tab characters and configure the tab key to indent as appropriate.

    Please, just stop using tab characters. They make code harder to maintain and are a pain.

    ---

    Monopolies = Industrial feudalism

  28. Re:Why put tabs in code anyway? by shutdown+-p+now · · Score: 2

    I don't have to backspace many times when I remove nested loops

    Try Shift+Tab some time (usually applies to selection, or to current line if nothing is selected).

  29. Comment removed by account_deleted · · Score: 4, Insightful

    Comment removed based on user account deletion

  30. Re:How is newline invisible by poopdeville · · Score: 2, Informative

    If \r and \n are "visible", then so is \t.

    --
    After all, I am strangely colored.
  31. Oh cry me a river by overnight_failure · · Score: 3, Funny

    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!

    *sigh*

  32. Re:Why put tabs in code anyway? by emt377 · · 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.

  33. Re:How is newline invisible by Qu4Z · · 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.

  34. Re:Why put tabs in code anyway? by Haeleth · · Score: 2, Interesting

    No, the simple solution is to use spaces for indentation, because then they appear the same everywhere automatically, without forcing you to individually reconfigure every single program you ever use.

    Besides, tabs have other purposes. Configuring my shell to display tabs as 2 spaces would break programs that actually use them for their intended purpose, i.e. displaying tables.

  35. Re:Why put tabs in code anyway? by osu-neko · · 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.

    --
    "Convictions are more dangerous enemies of truth than lies."
  36. TABs are for TABles! by mangu · · Score: 4, Informative

    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.

    1. Re:TABs are for TABles! by IBBoard · · Score: 2, Insightful

      Because using only spaces never causes confusion. Using only TABs can cause confusion in many cases, even if one never uses spaces for indenting.

      I'd disagree there, but to each his own.

      For example, you comment one line temporarily for a test. What happens to the tab that's now following a start comment character(s)?

      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.

      You merge two lines into one, what happens to the tab characters that are now inserted in the middle of a line?

      What happens to the spaces in that situation? Same thing.

      You break one line into two, will you need to convert the spaces into tabs?

      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.

      You cut and paste text from somewhere else, how will you make sure that the indentation contains only tabs?

      How do you know that the indentation contains only spaces? ;)

      Have you ever copied text from a web page? From a PDF file? From a scanned+OCR'd paper?

      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.

      We have one character that means 'blank', having another one just for the sake of the few people who want a specially personalized indentation is a complication we can live without

      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 ever be sure that in those and many other situations that all your lines contain the exact number of tabs?

      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.

      How can you be sure that your OCR, your document editor, and your PDF reader are configured to the same tab width as your code editor?

      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!

  37. Re:Let's sound like morons, anyone? by fedxone-v86 · · Score: 2, Funny

    This!

    --
    (USER WAS PUT ON PROBATION FOR THIS POST)
  38. Re:Why put tabs in code anyway? by harryjohnston · · Score: 2, 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.)

  39. Re:#include "less.h" by ljaguar · · Score: 2, Informative

    vim already does exactly this. http://vim.wikia.com/wiki/Modeline_magic

    it looks like this. (ts = tabstop, sw=shiftwidth) // vim: noai:ts=4:sw=4
          -or- /* vim: noai:ts=4:sw=4
    */
          -or- /* vim: set noai ts=4 sw=4: */
          -or- /* vim: set fdm=expr fde=getline(v\:lnum)=~'{'?'>1'\:'1': */

    so using your example: /* MS_VC_INTENT=2; MS_VC_TAB=4 */

    if you put on top of your file, // vim: set tabstop=4 shiftwidth=2

    then vim will do the correct thing.

  40. Re:Why put tabs in code anyway? by gazbo · · Score: 3, Informative

    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.

  41. Re:Why put tabs in code anyway? by mqduck · · Score: 2, Informative

    I see an ordered, numeric list. What are you seeing?

    --
    Property is theft.
  42. A Tab is 8 spaces nothing more, nothing less by smartin · · Score: 2, 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.

    --
    The difference between Canada and the USA is that in Canada healthcare is a right and gun ownership is a privilege.
  43. Re:Why put tabs in code anyway? by delinear · · Score: 2, Funny

    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.

    FTFY

  44. Re:Most editors do this... by Anonymous Coward · · 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.

  45. Thoughts on Windows 7 by killmenow · · Score: 2, Informative

    Subject: ASSERTION

    Body: NOTHING RELATED TO ASSERTION

    You assert Windows 7 sucks but have nothing in your post's body to suggest why you assert this. I would like to know what's so bad about Windows 7 (other than it being a closed-source proprietary operating system).

    Because...I hate Microsoft's business practices. I hate the unethical behavior of the company's directors and executives. I hate many of their products because many of their products are de facto industry standards despite being demonstrably garbage. But I'm running Windows 7 Pro x64 now and you know what? I hate that I like it so much. Unlike the vomit-inducing Vista, Win7 does everything I want and feels as good with resources as XP, runs all the Windows specific apps I need without anally raping me with a bottle of WINE, drives multiple monitors without a hitch, has a sensible audio subsystem, a clipboard system that isn't all over the place, and runs VirtualBox with any and every Linux guest OS I need without as much as a hiccup.

    Sure, YMMV but IMHO 64-bit Windows 7 is absolutely the best operating system ever to come out of Redmond, WA. Is it perfect? Of course not. There's no such thing as a perfect OS. But I think it's pretty damn good. And this disturbs me.

    So please help me hate Windows 7. I feel dirty.

  46. Re:Tabs suck. Use a space. by smellotron · · Score: 3, Informative
    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.

    L
    __L
    ____L
    ______L
    ________L
    ________L
    ________L
    ________L
    ________L
    ____|

  47. hard tabs are environmentally friendly. by tomhudson · · Score: 2, Interesting

    One true tab.

    It's not like we don't have large enough monitors to accommodate it.

    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.

    End result - shrunk it from 21 megs to 2.

    WTF is wrong with using a hard tab? Hard tabs mean less data to read and write, fewer characters to interpret at runtime, etc. The hard tab is not only good for performance, it's environmentally friendly.