%SCRIPT
env = triggerMatches\[1\]
txt = "\\begin{"+env+"}\n"
txt = txt+"\n"
txt = txt+"\\end{"+env+"}"
cursor.insertText(txt)
cursor.movePosition(1, cursorEnums.Up)
cursor.movePosition(1, cursorEnums.StartOfLine)
使用触发器:begin(\S+)\s
因此,当我写入begindefinition
并单击空格时,结果是:
\begin{definition}
|
\end{definition}
但是当我在点击空格后做同样的事情时结果是:
(four spaces) \begin{definition}
| (without spaces before cursor)
\end{definition} (without spaces before \end)
答案1
你是指那样的事情吗?
%SCRIPT
spaces = ""
for (var i=1;i<=cursor.columnNumber();i++) spaces = spaces + "\t";
cursor.insertText("\\begin{"+triggerMatches[1]+"}\n"+spaces+spaces+"\n"+spaces+"\\end{"+triggerMatches[1]+"}")
cursor.movePosition(1, cursorEnums.Up)
扳机:begin(\S+)\s