I made a modification of the example given by UltiSnip doc:
snippet "be(gin)?( (\S+))?" "begin{} / end{}" br
\begin{${1:`!p
snip.rv = match.group(3) if match.group(2) is not None else "something"`}}${2:`!p
if match.group(2) is not None and match.group(3) != "proof":
snip.rv = "\label{"+t[1]+":}"`}
${3:${VISUAL}}
\end{$1}$0
endsnippet
which, compared to the original one add a \label{envname:}
and if the envname
is proof
then we didn't add it. This can be helpful when we write thm
environment, e.g.
be lem<tab>
will give
\begin{lem}\label{lem:}
<c-j>
\end{lem}
the only drawback is that, I don't know how to add a placeholder at the position \label{lem:$4}
. Any idea?