Sublime Forum

BracketHighlighter 2 Moar Bracket Powa!

#21

Love that you’ll allow custom bracketing definition… that’s killer. Count me in for testing!

0 Likes

#22

@SeanWcom Thanks!

0 Likes

#23

Preview of BracketHighligheter’s new wrapping feature.

I have always wanted a nice easy way to wrap selections with custom stuff. I just wanted for instance to select some text, and select a something to wrap it with: tags, brackets, compiler switches, other stuff.

ST2 does good with brackets, but so much with other stuff. So one of the things I wanted to do in BH2 was to add this kind of functionality. I wanted to be able to define starting selections, tabstops, and indent style if required.

As you can see, the first example wraps a function with a compiler switch in C. It has two tabstops, and it is blocked off when the wrapping occurs.
In the second example, we have some HTML code, that gets wrapped in a generic tag with two tabstops that both automatically get selected so you can change their name a the same time. Also it blocks off the content and indents it.


This can be applied to lots of stuff. Something I am starting find pretty useful.

Still have some stuff to work out on bracket swapping which might end up being a more simplified version of this. Swapping won’t auto indent etc, it will just replace the brackets inline. So you could turn curly brackets to square, or turn an #if/#endif condition into a #if/#elseif/#endif leaving the conditions in tact. I might add tabstops and auto selections to swapping as well. I think once I update the swapping stuff, I will setup the branch. I didn’t intend wrapping and swapping to turn into what it did…it just kind of did…so this will set me back a little. Wrapping is done, I just need to rewrite the swapping stuff.

0 Likes

#24

That is totally awesome facelessuser!

I suppose you are going to allow us to customize these automatic bracketing correct?

0 Likes

#25

[quote=“Eduan”]That is totally awesome facelessuser!

I suppose you are going to allow us to customize these automatic bracketing correct?[/quote]

Of course. The last thing I want to do is have people making requests to me for doing this in every language :smiley:.

So everything is generalized. Here is an example configuration (keep in mind, syntax is subject to change before the official release):

{ "enabled": true, "language_list": "HTML", "HTML 5", "XML", "PHP", "ColdFusion", "ColdFusionCFC"], "language_filter": "whitelist", "entries": {"name": "HTML/XML Tag", "brackets": "<${BH_SEL:NAME}>", "</${BH_SEL:NAME}>"]}, {"name": "HTML/XML Tag - Block", "brackets": "<${BH_SEL:NAME}>", "</${BH_SEL:NAME}>"], "insert_style": "block"}, {"name": "HTML/XML Tag - Block Indent", "brackets": "<${BH_SEL:NAME}>", "</${BH_SEL:NAME}>"], "insert_style": "indent_block"} ] },

Due to swapping behavior being different than wrapping, they will have separate definitions. I am not sure if they will exist in the same settings file or have a separate swap settings file. I really am looking at swapping and wrapping as separate sub-plugins. I toyed with finding a way to make the same definition work for both, but it just got ugly. Wrapping can surround text with anything. Swapping is specifically swapping out the brackets that BH highlights.

0 Likes

#26

Usage currently is select text, invoke wrapping shortcut, and use fuzzy panel to pick what you want to wrap with. So it won’t be automatic, but still pretty quick compared to how it was before.

0 Likes

#27

OK, well be sure that I’m gonna check them out, even though I don’t know Python, I guess I’m gonna have to learn. :wink:

Anyway, looking forward to it. :smile:

Edit for new post: That is even more awesome! :stuck_out_tongue:

0 Likes

#28

Can’t wait for this

0 Likes