[TxMt] balance braces

Thomas Aylott - subtleGradient textmate at subtleGradient.com
Thu May 1 20:41:44 UTC 2008


On May 1, 2008, at 1:39 AM, Artie Ziff wrote:
>> Done. For HTML & XML that is.
>> Check out the Experimental bundle.
>>    http://macromates.com/svn/Bundles/trunk/Bundles/Experimental.tmbundle/
>>
>>
> That's great to know about. It does a minimum of the "balance"
> functionality, IMHO. However, it appears to be some what finicky
> regarding which side of the brace one's cursor is on. So it's clunky  
> at
> best. Though I am happy to learn about the single level of balance
> feature that it offers. It will be useful for occasional use. A former
> user of the "the app formerly known as the mac programmers first  
> choice"
> would expect a much more refined implementation.
>
> For a more refined version, imagine expanding the first selection
> wider... to the next larger scope of balanced braces by repeating the
> keystroke, and again.
>
> And then picture using your mouse to click once on any brace and the
> respective block of code is selected to balance the brace that was
> selected with the mouse. (up or down the document) [[ actually it's a
> single mouse-down while a modifier key is pressed.]]
>
> I think those features are useful when surfing through new code  
> written
> by someone else.   :)
>
> I am presuming Allan would be needed for some of those aspects.
> Though if the internal architecture of Textmate does not support this
> feature, then that is understandable.
>
> Cheers!

The current implementation actually has two ways to operate. Either  
like Dreamweaver or like BBEdit (yes, it's ok to say their name, they  
can take it).

The normal dreamweaver-esque one is repeatable. I don't think the  
other is.
Yes, it does matter which side of the tag your cursor is on. It might  
make sense to make it also work for the opening tag on the current  
line when the cursor is in the leading space of that tag.

TM2 may offer more options as far as activating commands with the mouse.

Also you may want to check out Balance Jr from my subtleGradient  
bundle on GitHub.
That bundle is just a pile of random stuff, so you can just rip the  
specific commands and macros you want out of it and double-click them  
to install in your personal bundle.

Doing a balance command is extremely complex and I'm incredibly  
impressed by Hans-Jörg Bibiko's super-awesome implementation. Although  
I'm certainly not against improvement. 


More information about the textmate mailing list