我修改了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
,与原始版本相比,添加\label{envname:}
,如果envname
为proof
,则我们无法添加thm
。当我们编写be lem<tab>
环境时,这可能会有所帮助,例如
\begin{lem}\label{lem:}
<c-j>
\end{lem}
会给出
\label{lem:$4}
唯一的缺点是,我不知道如何在位置> grant all privileges on your-database-name.* to 'php'@'localhost' identified by 'your_pass_here';
> flush privileges;
添加占位符。有什么想法吗?
答案 0 :(得分:0)
我得到了一个工作版本,但代码不干净:
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]+':'`$4`!p
if match.group(2) is not None and match.group(3) != "proof":
snip.rv ='}'`}
${3:${VISUAL}}
\end{$1}$0
endsnippet