Sublime Forum

auto_match_enabled doesn't work in html tags

#1

I’ve been using Sublime for about 3 years and never encountered this problem before.

The problem is that I write some bracket or quote inside an empty html tag those will not get matched unless I put some spaces inside the html tag. It seems some regex error where the brackets and quotes don’t get recognised because of the “><” characters.

Anyone knows how to solve this?

So for example these do not get matched.

<span>{</span> <span>"</span> <span></span>

But these will

<span> {} </span> <span> ] </span> <span> "" </span>

I’ve never had to put those characters in an html tag before, but now I’m doing some angular where this is very common:

<span>{{something}}</span>
0 Likes

#2

Brackets and quotes are usually not auto-matched when preceding a non-whitespace character or non-closing bracket.

In the default key bindings you can find that auto match will only be applied if the following regex matches (starting at the caret location, which^ anchors, and ending at the end of the line):

^(?:\t| |\)|]|;|\}|$)

For your case, you can just copy the respective binding from the default to the user file and adjust the regex to include <,

I guess this could be improved, however it’s rather hard to consider all the situations where auto-matching happens but you didn’t want it to. Ultimately we should aim to find a generally better regex somehow.
I can’t really think of a situation where you wouldn’t want auto-match to happen with a following < character. (It would be useful for writing a parenthesized expression in front of a binary lower operator operator without whitespace for example.)

1 Like