Sublime Forum

Bracket matching doesn't work before text or other special characters

#1

So bracket matching doesn’t work before text. So, for example, if you type in { in the line below:

This is a |sentence

the bracket will not be matched.

I use LaTeX and often I have a dollar sign after the cursor:

$x = \frac|$

I often need brackets to be matched in this type of situation (where the cursor is before a $). However, it seems like brackets aren’t matched before dollar signs.

Is it possible to “fix” this or make it work before dollar signs? I always have to insert a space before the dollar sign, type it out, remove it, which is kind of cumbersome.

0 Likes

#2

Also doesn’t work before periods I see

0 Likes

#3

You also want to insert {|} instead of {| inside latex files? Just add this keybinding:

    {
        "keys": ["{"], "command": "insert_snippet", "args": {"contents": "{$0}"}, "context":
        [
            { "key": "selector", "operator": "equal", "operand": "text.tex.latex" },
            { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            // add other characters in the next line
            { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\\$|\\.)", "match_all": true }
        ]
    },
1 Like

#4

Nice, thanks a lot!

You made LaTeXTools, right? You rock!

1 Like

#5

Yes, I am one of the LaTeXTools developers.

Thanks :slight_smile:

1 Like