Elastic tabstops - a better way to indent and align code

Support for more editors in the works

Visual Studio 2010

Following my last post last year (I really should try and post more frequently), someone from the Visual Studio development team at Microsoft got in contact with me (thanks Noah!). It looks like I will be able to implement elastic tabstops in Visual Studio after all, since VS 2010 should allow me to set non-uniform tabstops on different lines. I think I'll wait until the final version's released before I do anything else.


I had a look into what it would take to get elastic tabstops working on Eclipse. Unfortunately it looks like SWT (the toolkit Eclipse uses) will not let one set non-uniform tabstops on different lines, which is a pre-requisite for the implementation of elastic tabstops. If you're an Eclipse developer (or feel like creating an account) you can vote this bug up here.


In contrast with Eclipse, NetBeans uses Swing, which is a toolkit that already supports the implementation of elastic tabstops (as can be seen in my demo applet here). When I get time I'll try and look into writing a plugin for this IDE.

Another editor supports elastic tabstops - Code Browser

Marc Kerbiquet emailed me last month to tell me that he'd added elastic tabstops to his editor: Code Browser. He's also written a rather nice advocacy page. Since it's cross platform this is probably the first editor to support elastic tabstops that runs on Windows. (There's also Gedit on Windows, which I'd like to see get more attention.)

Plans for an editor of my own

I'm planning to start work on a new cross-platform editor which will of course support elastic tabstops. I have a few innovations I'd like to try, but I also intend to borrow ideas from the best, and I'll also make it scriptable so people can extend it as they see fit. The reason for this is that changing every single editor that exists is impossible, but by making an easily scriptable cross-platform editor which supports elastic tabstops from the start it should be possible for people to script it to feel like their favourite editor. Watch this space...

Posted on Sunday, 2009-06-07 at 19:31 UTC


Tuesday 2009-06-16 20:50 UTC
David <david DOT regev AT gmail DOT com>
Nick, I think your idea is brilliant. I look forward to your progress. Regarding the innovations you'd like to try, I have an idea that I think is right up your alley and in line with the goal of elastic tabstops. Say I have a long indented line in an HTML document (the pipe indicates the end of the visible part of the line): &#8594; &lt;p&gt;The quick brown fox jumps over |the lazy dog.&lt;/p&gt; This, obviously, can get pretty annoying. To avoid this, I can enable word-wrapping in my text editor: &#8594; &lt;p&gt;The quick brown fox jumps over &#8626; the lazy dog.&lt;/p&gt; which disrupts the flow of the document and its semantic indentation, making it quite hard to read. Alternatively, I can hard-wrap the text: &#8594; &lt;p&gt;The quick brown fox jumps over ΒΆ &#8594; the lazy dog.&lt;/p&gt; which is hard to maintain and uses the line feed and following tab in a completely nonsemantic manner. This choice between two evils has bothered me for a long time, until I realized that there is a third, more humane, option: the text editor should wrap to the last inserted tab in that line: &#8594; &lt;p&gt;The quick brown fox jumps over &#8626; &#8594; the lazy dog.&lt;/p&gt; So, just like elastic tabstops solve the tab vs space issue by making tabs more semantic, this idea would solve the soft-wrap vs hard-wrap issue by making line feeds more semantic. In essence, your innovation would be expanded from "elastic tabstops" to "semantic whitespace". As far as I know, the only editors that implement this are Kate and KWrite, which call it "Dynamic Word Wrap" (though they wrap to the first set of tabs, rather than to the last tabstop). I would love to see this implemented in your gedit plugin. (I even found a Mozilla bug with this idea: https://bugzilla.mozilla.org/show_bug.cgi?id=312716 .) So, what do you think?

Monday 2009-06-22 13:59 UTC
I like that feature too, and I've seen it in a few editors before. I won't be adding it to the elastic tabstops plugin though as I think it's different functionality and should be in a separate plugin.

Friday 2009-06-26 14:20 UTC
David <david DOT regev AT gmail DOT com>
Nick, other than the two editors that I mentioned (Kate and KWrite), what other editors have you seen that have this? I've found it quite difficult to search for this feature, so I would not at all be surprised if it's more common than I thought. As I pointed out, those two editors wrap only to the opening tabstop of that line, rather than to the last tabstop on the line. They fail to account for elastic tabstops and their semantic nature. A properly-written "Dynamic Word Wrap" plugin would take your plugin into account and would work with it. The table-like layout that your plugin allows would only be enhanced. I really think that the two features compliment each other and go hand-in-hand. That's why I suggested this idea to you. Do you think you might be able to create such a plugin in the future? Thanks.

Sunday 2009-06-28 19:06 UTC
I think I've seen this feature on an editor called Crimson Editor on Windows, and I would expect Emacs could do this as well as possibly Vim. While this won't be part of my elastic tabstops plugin for Gedit, I plan to write my own editor at some point, and since this is a feature I've always liked I'll try and add it to that.

Monday 2009-06-29 07:08 UTC
David <david DOT regev AT gmail DOT com>
Indeed, Crimson Editor does support what it calls "natural word wrapping". Of course, it does not work in the table-like manner that I described. I hope you will be able to do that in your own editor. I did some more searches, and it seems that I'm not the only one dying for this feature. This guy[1] went on a quest for a text editor that has it, finding only Kate. Someone asked for it on Stack Overflow[2] as well. And bugs have been filed both on Launchpad[3] and GNOME's Bugzilla[4]. Thanks for the references. I look forward to trying your editor when its ready. [1] http://null.maimed.org/articles/questfortheeditor.shtml [2] http://stackoverflow.com/questions/662823/text-wrapping-in-gedit [3] https://bugs.launchpad.net/gedit/+bug/318517 [4] http://bugzilla.gnome.org/show_bug.cgi?id=559132

Wednesday 2009-11-04 08:43 UTC
Graeme Geldenhuys <graemeg AT gmail DOT com>
Hi David, Lazarus IDE and Delphi IDE has supported what you suggest for years already. It's called "auto indent" or "smart tabs" in Lazarus.

Friday 2010-01-08 20:54 UTC
Dan Bernier <danbernier AT gmail DOT com>
Hello Nick, any word on the VisualStudio 2010 plug-in?

Wednesday 2011-10-19 07:06 UTC
Karl Ostmo <kostmo AT gmail DOT com>
I would love to help with any effort to implement Elastic Tabstops in Eclipse. Has anyone started this effort? Judging from the Eclipse Bugzilla reports, it looks like the way is paved to begin.

Friday 2015-10-23 19:28 UTC
Steve Paschall <stephen DOT paschall+nickgravgaard AT gmail DOT com>
Just wondering if you've seen any more interest in this lately, Nick. I've been a fan of the idea for years now. Anyone actively working on Eclipse support that you're aware of?

Comments are closed.