Elastic tabstops – a better way to indent and align code
nickgravgaard.com
nickgravgaard.com
So yes, these would be nice and would improve my coding experience. But the improvement would be tiny compared to the fight of trying to get everyone to use them.
IE:
doSomething() // This is a comment
...random other things here...
doSomething2() // This is another comment, I want aligned with the first
That can be done with tabs/tabs replaced with spaces. I just need to hit tab until it aligns with the same tab boundry. But can elastic tabstops do that?> Elastic tabstops require editor support, and editor support is lacking
This can change. Inserting multiple spaces when you press "tab" also used to be lacking in most text editors, now it is ubiquitous. We can likewise push for elastic tab stops
> Elastic tabstops cannot adequately represent the code sample above. Under elastic tabstops, there would need to be a tab on the first line....
Not necessarily. The way I envision elastic tab stops is you can configure the IDE to typeset the file exactly how you like it. So you can tell the IDE to align function arguments. Or align `=` signs. And the IDE intelligently parses the code and figures out the correct indentation and alignment for each character. Maybe there's a file where the IDE can't parse it correctly. Ok, just disable intelligent indentation for that file, and it will display it in plain view.
One benefit to this approach is that different people can have different preferences. This is similar to how you can already configure your IDE to change indentation width (if you use tabs for indentation). Just like how one person might like 2-char width indentation while others prefer 4-char width, one person might prefer aligning function arguments while others don't. These can all be configured. And if the user doesn't want to configure, the IDE comes with sane defaults.