{"id":154,"date":"2006-07-03T19:38:32","date_gmt":"2006-07-04T02:38:32","guid":{"rendered":"http:\/\/www.red-sweater.com\/blog\/154\/elastic-tabs"},"modified":"2006-07-04T07:58:43","modified_gmt":"2006-07-04T14:58:43","slug":"elastic-tabs","status":"publish","type":"post","link":"https:\/\/redsweater.com\/blog\/154\/elastic-tabs","title":{"rendered":"Elastic Tabs"},"content":{"rendered":"<p>Nick Gravgaard has come up with a pretty simple solution to the &#8220;tabs vs. spaces&#8221; problem. He proposes a system for the <a href=\"http:\/\/nickgravgaard.com\/elastictabstops\/\">elastic interpretation of tabs<\/a> (via <a href=\"http:\/\/www.joelonsoftware.com\/items\/2006\/07\/03.html\">Joel<\/a>) by text editors. Basically it comes down to treating tabs as indicators of a &#8220;new column,&#8221; instead of assigning an arbitrary number of spaces to them. The graphic on his page explains it better than I can with words.<\/p>\n<p>\nA major drawback that he points out is poor readability in older (i.e. all current existing) editors, but maybe it will catch on. I think it&#8217;s really cool that you could, for instance, lengthen one line in a block-comment and all the other lines would automatically grow to match that column&#8217;s new width. How many times have changed a comment like:\n<\/p>\n<p><pre>\n\/* Juicy bits of  *\/                \/* Juicy bits of     *\/\n\/* info for our   *\/   ----TO--->   \/* info for our best *\/\n\/* client.        *\/                \/* client.           *\/\n<\/pre>\n<\/p>\n<p>\nExtending the second line meant you had to &#8220;up the tab ante,&#8221; by manually clicking all the other lines of the block comment and tabbing out <em>its<\/em> final characters, as well.\n<\/p>\n<p>\nI think his system would work well for me in most instances, though I&#8217;m slightly concerned that sometimes my code does not fit well into discrete columsn. Maybe it&#8217;s just poor style on my part, but for instance I could see myself writing something like this:\n<\/p>\n<p><pre>\nint doodad;   \/\/ what a thing;\nint flubber;  \/\/ also neat\ndoodad = doSomethingFunnyAndScary(flubber);    \/\/ Not too shabby...\nflubber = andTheOppositeCouldAlsoRock(doodad); \/\/ Lovely!\n<\/pre>\n<\/p>\n<p>\nIn other words, sometimes I end up with localized tab-aligned comments that, to remain pertinent to their target, are kept pretty close (just one tab away). Now in Nick&#8217;s system, the &#8220;column system&#8221; for any chunk of code is uniform until a blank line is encountered. So the above would probably end up looking more like this:\n<\/p>\n<p><pre>\nint doodad;                                    \/\/ what a thing;\nint flubber;                                   \/\/ also neat\ndoodad = doSomethingFunnyAndScary(flubber);    \/\/ Not too shabby...\nflubber = andTheOppositeCouldAlsoRock(doodad); \/\/ Lovely!\n<\/pre>\n<\/p>\n<p>\nIt would be easily solved in this case by putting a blank line (which is probably appropriate anyway) between the variable declarations and the code. But I&#8217;m not sure yet that all cases would be so easily &#8220;fixable.&#8221; Still, an excellent experiment and I&#8217;ll be curious to see if any major editors incorporate the technique as an option.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nick Gravgaard has come up with a pretty simple solution to the &#8220;tabs vs. spaces&#8221; problem. He proposes a system for the elastic interpretation of tabs (via Joel) by text editors. Basically it comes down to treating tabs as indicators of a &#8220;new column,&#8221; instead of assigning an arbitrary number of spaces to them. The [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,19,12,5],"tags":[],"class_list":["post-154","post","type-post","status-publish","format-standard","hentry","category-programming","category-technology","category-usability","category-xcode"],"_links":{"self":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/comments?post=154"}],"version-history":[{"count":0,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/154\/revisions"}],"wp:attachment":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/media?parent=154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/categories?post=154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/tags?post=154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}