Elastic tabstops - a better way to indent and align code

"Elastic tabstops lite"

I was contacted the other day by someone who works on Ace, an open source browser based text editor, to tell me that he's been working on a version of elastic tabstops based on the Sublime Text editor extension at https://github.com/SublimeText/ElasticTabstops. This sounded great until I realised that the extension does not actually implement elastic tabstops at all. Apparently some users of Sublime Text had been asking for elastic tabstops but since that editor doesn't have an API which allows users to set tabstops at non-uniform positions on different lines, and since it's closed source so there's no way for them to change the API, they came up with a hack instead. This hack looks at cells above and below the one that's being edited and appends/removes spaces to/from the ends of them to keep things lined up. It changes the contents of the buffer (ugh!) rather than changing the view.

This does keep things aligned but it has some significant disagvantages over proper elastic tabstops:

Inserting spaces in the buffer to push text to the next fixed tabstop position is obviously an ugly hack but I'm charitably going to call this "elastic tabstops lite" since it does have a similar effect even if the tabstops aren't being moved at all. If you end up implementing this hack, please use the name "elastic tabstops lite" so that users don't get confused.

Posted on Monday, 2012-12-17 at 11:23 UTC

1 comments


Thursday 2012-12-20 18:20 UTC
no spam please <no AT spam DOT com>
I'm glad you're still working on this thing. Good idea calling this "elastic tabstops lite" to differentiate it from the original version. I hope one day such hacks won't be necessary because text editors will have the API calls we need. An aside: unless you're developing for Windows or Apple (where everyone's pretty much forced to use Visual Studio or Xcode) why do programmers use closed source editors at all?

Comments are closed.