+1
Elastic tabs
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.
Thanks but it donât work for me
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
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()
If you like this feature, please vote up : sublimetext.userecho.com/topic/1 ⊠p-feature/
If anybody is looking for the elastic tab stops code, it apparently has moved to github.com/SublimeText/ElasticTabstops
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.
This does not work at all with a proportional font!
PS: I had not realized this thread was old. But itâs still not working!
[quote=âtobiaâ]This does not work at all with a proportional font!
PS: I had not realized this thread was old. But itâs still not working![/quote]
Unfortunately thereâs no way to get it to work with a proportional font: the API doesnât allow either determining character width or inserting arbitrary-width spaces. The first could be worked around by opening the font myself and figuring out the character widths, but the second is a dealbreaker. Sorry!
Any chances that with the advent of ST3 elastic tabs could become reality?
No, we still donât have API support. This plugin is as close as you can get (and it doesnât yet work in ST3 due to API changes).
While Iâm not a fan of elastic tabs per se, I do feel thereâs room for improvement in Sublimeâs tab handling, the implementation for which should be fairly straightforward.
What Iâm talking about here is simply definable tabstops. Just about every decent editor has this, and itâs essential if an editor is to become a programmer or technicianâs âgo toâ for editing any kind of text files in the field. I have to drive another editor simply because Sublime is lacking in this basic area. And itâs a showstopper for a whole bunch of colleagues.
So, my old favourite âBriefâ had simply a command âtabsâ that went something like this âtabs 5 25 40 45â. That would define tabstops for the current buffer at those positions, and the remaining tabstops would be at a repeating interval of the last two (50,55,60,65 etc.). Some editors augment this by allowing tabstops to be left, centre and right aligned, though I see this as fairly pointless and only useful for formatting tables that are coded into tab delimited text files (in that case, you may just as well load stuff up in your favourite WP)
This is needed because text output files from numerous sources are tab delimited, and itâs not possible to work with such files formatted even remotely correctly in Sublime. Traditional programmers prefer this approach since it gives flexibility as to how things are spaced out horizontally. Moreover, a number of older, less popular programming languages work with particular indentation positions. The above tabstop model would support use of tabs or spaces in much the same way that Sublime does presently; knowing tabstop positions allows Sublime to convert tabs to spaces and spaces to tabs in the same way it does at present.
Sublime is already set up with very flexible configuration for this with its default, user, filetype and project preferences.
this would drive me absolutely CRAZY if i had the feature turned on.
it would drive me absolutely crazy if you didnt
[quote=âmark4â]this would drive me absolutely CRAZY if i had the feature turned on.
it would drive me absolutely crazy if you didnt [/quote]
Wait, what?
[quote=âadzenithâ]
[quote=âmark4â]this would drive me absolutely CRAZY if i had the feature turned on.
it would drive me absolutely crazy if you didnt [/quote]
Wait, what?[/quote]
Lol⊠One of the things im MAJORLY anal retentive about is source formatting. Cluster $*&# scatterbrain source formatting just drives me up the wall. I always indent by the same distance and always using spaces NEVER tabs. I always place my comments in the same column (i avoid interleaving comments with code etc). My source formatting is very VERY consistent across all my source files!
Having my indentations automaticlaly adjust themselves as i wrote code would be like eating garlik flavored ice cream⊠just WRONG!
but 99 times out of 100, when i look at someone elses sources which are cluster *$%! scatter brained i have to first reformat them just to be able to read them and retain what little sanity i have left. If you (they?) used this auto formatting even if the end result was not exactly to my liking it would be MUCH MUCH more consistent within the source file. So⊠i could not use this feature if it was ever implemented but if everyone else did it would be cool
thats what i meant ~
Does it tell you what tab stop youâre at? Meaning which visual tab stop a given tab character is aligned to? If it does, then you could have an option to insert consecutive tabs to fake the elastic tabstops, instead of spaces. So that the plugin would only have to change the number of consecutive tab characters to keep the columns aligned. It would sometimes waste a bit of space, as in this example, but it would not be too bad.
No, thereâs no way to find out what tabstop youâre at. Scenarios like this are difficult:
[quote]iiiii â„ â„
mm â„
[/quote]
The tabs are being translated to single spaces by the forum software, unfortunately, but five iâs need two tabs, and two mâs need one tab, and thereâs no way to figure that out using the Sublime API â youâd have to figure out what font is being used and do the math yourself.
Support for ST3 has been added! Woo!
Thanks to lunixbochs for the edit abstraction.