snippet有什么好办法可以自动匹配括号?

\left${1:$$(yas/choose-value '("[" “|” “(” “{” “<”))}\begin{array}{ccc}

$0

\end{array}\ritht{${2:$$(yas/choose-value '("]" “|” “)” “}” “>”))}}

2处的括号可以自动匹配1处选择?

利用镜像来实现:

${1:$$(yas-choose-value '("[" "(" "{"))}
    foo$0
${1:$(cdr (assoc yas-text '(("(" . ")") ("[" . "]") ("{" . "}"))))}

参考: https://joaotavora.github.io/yasnippet/snippet-development.html#orge2c1f71

2赞