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 disadvantages over proper elastic tabstops:
- only works with monospaced fonts
- means text cannot be replaced outside the editor through the use of sed etc. and still line up
- mixes tabs and spaces
- columns of text suddenly jump to the next fixed tabstop position once a cell gets too wide
- obviously an ugly hack
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
Comments are closed.