Sublime Forum

How does tag matching work?

#1

How does the tag matching in XML and HTML work?

I’ve looked in the .tmLanguage files (and tried twiddling them a bit), but can’t locate what indicates a matching tag and how to handle it.
I’ve also searched the forums for the relevant feature, and noted some posts from years ago noting the lack of such feature, but no announcement for when it was added (as I figured that might have some details).
It seems that the functionality is built into the highlighting engine rather than through a plugin, though I’m not sure.

The purpose of my explorations is to build something similar for a language that has a somewhat similar syntactic feature, with blocks delimited like so:

(outer
    (inner
        stuff
    )inner
)outer

And I’d like to implement a similar matching feature. I’d also like to be able to use the “close_tag” command to close the blocks, but it seems that functionality is baked into Sublime. If I get lots of energy I might have to figure out how to duplicate such a feature in a package, but first I’ll take highlight matching.

0 Likes

#2

Have you tried Bracket Highlighter?

0 Likes

#3

No, I hadn’t seen that. Looks like I should be able to bend that to my will, especially since I’d also like to fill in or change the closing tag based on the opening one.

I’m still interested in how the base system works, but the Bracket Highlighter should get me going for sure. Thanks!

0 Likes