Elastic tabstops is not yet a common feature in text editors, so I want to add my 2 cents to explain benefits and bust some myths.
The original proposal by Nick Gravgaard can be found at http://nickgravgaard.com/elastic-tabstops/.
"It can be solved with spaces"
No it can't ! Try with proportional font.
"Oh, who needs that ?" - well that's an entirely different question.
"Tabs for indentation, spaces for alignment"
A mantra repeated ad-nauseam but it doesn't work, you can't align text with spaces when using proportional fonts.
"Proportional font for programming is a nonsense"
Using proportional fonts in programming is not new, Smalltalk developpers have been using it for ages.
A 'w' is wider than 'i', so why should they have the same width ? Monospaced fonts are relics of typewriters and early computers.
Proportional font for programming is a nonsense only if you are programming in Befunge.
"Using elastic tabstops makes program unreadable with other text editors and viewers"
- It's already true with misconfigured tab sizes.
- Indentation (tabs at the beginning of the line) works in the same way with and without elastic tabstops.
- Tabs other than indentation should be used very locally (group of assignments, function's arguments, data, ...), so it shouldn't make the whole program "unreadable".
- People using Code Browser don't care too much of the rendering in other editors as the rendering is already polluted with fold markers :-)
Lines in a "group" are automatically aligned when editing a line. It is no longer necessary to fixup alignment manually or using a macro.
When adding a new line, all previous lines are automatically aligned:
Solve alignment issues with proportional fonts
Alignment is impossible with spaces when using a proportional font and it does not work better with tabs as the alignment is broken as soon as you change the font.
Elastic tabstops make obsolete the developer's arguments "I can't use proportional font because I can't line up code".
Save memory and disk space
Tabs consumes less memory than expanded spaces: it saves disk space and makes compilations faster... ok, may be not so faster.
LimitationsThe elastic tabstop feature is not the silver bullet to solve every situations.
Mixing indentation and alignment
It is not possible to mix indentation and alignment in the same group.
You have to insert an empty line to split groups or put comments above.
Elastic tabstops won't solve all alignment issues but it is really a powerful tool to easily align text and keep it aligned.
Examples of Use
This is just some examples for maniacs like me who like to line up everything.
Switch/case statements are very table-oriented.
An unexpected benefit is the readability of tabulated files:
The Perfect Tool for Assembly
Elastic tabstop is the perfect solution for assembly programming where the source code is very column oriented: label, mnemonic, operands and comment columns.
After almost 10 years of using elastic tabstops, I'm adding a personal feeling on this feature.
At the beginning, I was putting tabs everywhere, but I found that there were some cases where it was not very elegant, especially with a group of few lines with a huge width difference:
So, now, I'm using it in a more moderate way.
As I am using proportional fonts for everything, even C++ programming, elastic tabstops is a must for structures and function headers:
I use it less in the rest of the code, but in big constructors, it also helps readability:
It is easier to quickly spot a particular attribute than:
I have been tempted to remove elastic tabstops from Code Browser as I want to keep it as simple as possible and Elastic Tabstops makes the edit component complex: it requires to store and maintain group of tabs to keep them aligned. It also consumes a lot of extra memory in order to be fast.
But I can't remove it, it's really a must-have feature when you program with proportional fonts.