Sublime Forum

Elastic tabs

#1

As Sublime Text is THE cutting-egde-text-editor, it could be interesting to implement this: nickgravgaard.com/elastictabstops?

What do you think?

4 Likes

Congrats on the new forum
#2

really nice, but what if i open this file in another ‘plain’ editor, i will see a mess… as well as if i send this file to a friend, etc. the problem is it is not standard behavior.

0 Likes

#3

Yeah, it should be optional, of course…

… or implemented as a plugin, if possible.

0 Likes

#4

Upvote! End the tabs vs. spaces war!

0 Likes

#5

Another upvote. This would be a marvelous option.

0 Likes

#6

Actually, when the file is opened in another editor, it looks perfect, because the file is saved with spaces only.

It’s been done for gedit (nickgravgaard.com/elastictabstops/#gedit). When you open the file, it’s internally converted to tabs, and when you save it, it’s converted back to spaces.

I think we could make this work in Sublime if there was a way to set non-uniform tabstops on different lines.

0 Likes

#7

I just wanted to bump this thread! :smile:
Will we see something like this in Sublime Text X?

0 Likes

#8

Awesome ! A must have !
I want this feature !

0 Likes

#9

I’m personally not a fan of elastic tabstops, primarily because they significantly increase the cost of laying out text: it changes the problem from a local, per-line one, into a global problem: a modification on one line can change how every line in the buffer is rendered.

Although I haven’t used any software that supports elastic tabstops, I suspect that in the real world, they aren’t as handy as they seem: because layout is now global, a very long variable name in once function can introduce excessive whitespace in every other function in the file (i.e., blocks will be aligned with other blocks hundreds of lines away).

The primary problem elastic tabstops solve is preserving vertical alignment of neighboring blocks of text. I believe this would be better solved by the editor doing so explicitly, inserting normal whitespace as required.

2 Likes

#10

I don’t understand why you speak of align the whole text and at the end only of lines above or belove the current line.
The elastic tabstop works only for the lines above or belove the current line when you have at least N numbers of elastic tabstop, where N is greater than or equal the N of the current line.

0 Likes

#11

As oxman said, you only need to look at nearby lines that are similarly tabbed. There’s a Java applet at this page that lets you play around with elastic tabstops.

I’ve actually been thinking about making a Sublime plugin that replicates the behavior of elastic tabstops through capturing the tab key and replacing it with a certain number of spaces, then looking at nearby lines and modifying them. If I find some time I’ll throw something together. This use of spaces instead of tabs would also mean that the text would be completely portable into other editors.

0 Likes

#12

Oh, yes, my mistake!

This is a problem better solved in the editing layer rather than during layout, however.

0 Likes

#13

+1 for this feature :smile:

0 Likes

#14

If you like this feature, you can vote on sublimetext.userecho.com/feedbac … p-feature/ :wink:

1 Like

#15

Unless we use proportional fonts.

With elastic tabstops and better looking special characters, using proportional fonts could be cool.

Imagine using a serif font for large comments, and a sans serif font for code.
And bigger character size for class declarations, and for

tags.
And array indices in superscript.

Maybe I’m a bit crazy, but compare a nicely rendered math formula to a plain text one in notepad…

Clicking on the minimap should also act like google earth: zoom out until the destination is visible, then zoom in, closing in on the destination rectangle.

I also want particle effects on syntax errors.

Of course, I’ll still be happy if these features only make it in 2.1 :confused:

Seriously though… A pretty-printer/code-beautifier can do the same job as elastic tab stops.
Unless we use proportional fonts.

0 Likes

#16

I would never use this. It’s a very cool thing, but a) I use spaces, and b) it would be a major visual disruption if it started working when you didn’t intend it to.

Seems like a lot of interface work just to help make your code pretty. And as others have mentioned, exporting to an editor which didn’t have this feature would expose your “pretty” code for the mess it really is. I downvote.

0 Likes

#17

No, the file would be saved with spaces

0 Likes

#18

I don’t see why this wouldn’t be possible with a plugin to be honest. You’d only need to look between regions and the current line.

Not saying I could do it, but from what I understand of the plugin system (at least in V1.4) I see no reason for it not to be done?

0 Likes

#19

I’m actually working on a plugin for elastic tabstops right now.

0 Likes

#20

[quote=“adzenith”]

I’m actually working on a plugin for elastic tabstops right now.[/quote]

Cool! Looking forward to seeing it!

0 Likes