I'm trying to write a pretty innocent looking snippet for ST3. To insert
\left<open-parens> \right<close-parens>
in a latex document, while in the field of mathematics.
Now I have the following:
<snippet>
<content><![CDATA[\\left${1:(} $0 \\right${1/(\()|(\{)|(\[)/(?1:\))(?2:\})(?3:\])/}]]></content>
<tabTrigger>lft</tabTrigger>
<scope>text.tex.latex string.other.math.tex,meta.function.environment.math.latex</scope>
</snippet>
Use is understood as follows:
- Enter
lst, tab; \left( \right)inserted with the selected (;- If the user wants
(to tabland in the middle, - Else type
{or [have matching closing parsers inserted after\right
I checked that the regex works as intended (by checking the versions of the fragment with ${1:(}replaced by ${1:{}and ${1:[}.
, , ST , a) parens b) , .
, , , . :
{ "keys": ["{"], "command": "insert_snippet", "args": {"contents": "$0{"}, "context": [
{"key": "selector", "operator": "equal", "operand": "text.tex.latex string.other.math.tex, meta.function.environment.math.latex"},
{"key": "preceding_text", "operator": "regex_contains", "operand": "\\\\left\\($", "match_all": true }] },
, ).
:
- ,
"key": "preceding_text". - - (..
[ lst-).
?