Sublime Forum

Modify auto-complete for multi-character brackets? (LaTeX)

#1

I searched around a bit for this, and it seems like there should be a way to fix this pretty easily, but I can’t quite figure it out.

When I’m in a LaTeX document, and I open math mode with “(”, the auto-complete gives me a “)”. (And similarly for “” and “]”)

I’d like for ST2 to either ignore the left bracket (maybe it could recognize the escape sequence?), or, even better, auto-complete it with a two-character sequence, “)”, or “]”, as appropriate.

A snippet would work, but that would require disabling auto-complete for brackets since the snippet fires after the auto-complete places the extra bracket at the end (which you can’t tab past to escape the snippet scope, since it isn’t in the snippet).

I would like to keep auto-complete on for non-escaped brackets, but if turning it of is the easiest way to deal with this, I guess I can live with it… although I’m not sure of all of the ramifications of doing that.

Do most people turn off auto-complete for brackets in LaTeX files? Am I missing another way of dealing with this?

0 Likes

#2

I’m having the same issue, can anyone help?

0 Likes

#3

For now I’ve just disabled auto-complete for brackets in LaTeX files, and I have two snippets that are getting the job done.

One for math mode:

<snippet>
	<content><![CDATA[
\($TM_SELECTED_TEXT$1\)
]]></content>
	<tabTrigger>\(</tabTrigger>
	<scope>text.tex.latex</scope>
</snippet>

and one for display math mode:

<snippet>
	<content><![CDATA[
\($TM_SELECTED_TEXT$1\)
]]></content>
	<tabTrigger>\(</tabTrigger>
	<scope>text.tex.latex</scope>
</snippet>

Does anyone have a better solution to this? Thanks.

0 Likes