[SVN] Re: Align Source
mailinglist at textmate.org
Fri May 20 12:35:45 UTC 2011
Thanks for sharing.
I’ve been meaning to rework this command for quite some time, the basic algorithm I want to do is here: http://pastie.textmate.org/747958
The align function takes a regexp which must have two captures. It match each line against the regexp and then ensures that spacing is inserted after capture one so that capture two falls on the same column for each line.
In the example we first match up to comma followed by a space, aligns on that, and then matches up to the closing brace, and align on that.
The thing I haven’t written yet is a way to automatically figure out the regexp from the user’s code. I think this would be possible with some heuristic which finds the first candidate character which exist for each non-empty line, and which isn’t already aligned. One could perhaps cycle through candidate matches on successive runs.
I’ve never gotten around to trying implementing such heuristic though.
On 17 May 2011, at 12:29, Mads Hartmann Jensen wrote:
> Hi guys,
> I've modified the align assignments command to take a string as input (using
> TextMate::UI.request_string) and use that to align your source code rather
> than just '='. It also fixes the annoying extra line that Align Assignments
> creates when aligning a selection.
> I've found this command very useful and thought I would share it:
> Mads Hartmann Jensen
> View this message in context: http://old.nabble.com/Align-Source-tp31636561p31636561.html
> Sent from the textmate-dev mailing list archive at Nabble.com.
> textmate-dev mailing list
> textmate-dev at lists.macromates.com
More information about the textmate-dev