Sublime Forum

Elastic tabs

#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.

1 Like

#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

#21

+1 :smile:

0 Likes

#22

Here it is:
github.com/SublimeText/ElasticTabstops

NOTES

  • You can’t use the stock undo/redo/soft undo/soft redo commands, and instead need to use the wrappers that I’ve created for them (in the same file as the plugin). This is because undo and redo trigger on_modified, and on_modified is where this plugin does all of its processing. So every time you undo, the plugin will redo what you just undid, effectively taking away your ability to undo. My wrapper functions warn my plugin that an undo is coming so that it stands down.

  • Because you can’t change the width of individual tabstops in Sublime Text, this plugin works by inserting spaces in front of tabs in order to align text. This has the benefit of making your files 100% compatible with editors that don’t support elastic tabstops, but adds a couple of quirks to the behavior of the plugin that pretty much can’t be worked around.

  • You’ll need to be indenting with tabs.

Let me know of any questions or comments!

Edit: updated link.

0 Likes

#23

Thanks but it don’t work for me :frowning:
Nothing happen.

And I want the same plugin work with space indentation.
And elastic tabstop in real time when I write.

Thanks for your work :smile:

0 Likes

#24

The elasticity does in fact happen in real time.
I want the same plugin with space indentation too, but it’s approximately impossible given Sublime Text’s API right now—with spaces you have to guess intent, whereas with tabs you just have to count tabs, and Sublime Text’s API doesn’t tell you what changes have been made to a buffer (it just tells you that changes have been made), so it’s hard to guess what’s going on.

In terms of the plugin not working, can you give me more info? Are your files using tabs for indentation? Is the plugin loading correctly? etc.
You can run this for a little info:

import sublime_plugin sublime_plugin.all_callbacks.items()

0 Likes

#25

If you like this feature, please vote up : sublimetext.userecho.com/topic/1 … p-feature/

0 Likes

#26

up :smile:

0 Likes

#27

If anybody is looking for the elastic tab stops code, it apparently has moved to github.com/SublimeText/ElasticTabstops

0 Likes

#28

Before SublimeText, I needed this feature. But now, I just use multi-select…

0 Likes

#29

I guess I don’t really see how one substitutes for the other. I use multi-select and elastic tabstops together and it’s fantastic. :smile:

0 Likes