Hi!
Is there a way to write a script that surrounds the current selection with a \begin{environment}..\end{environment}?
That is, if the text I have is
Line1 Line2 Line3 Line4 Line5
And the second line is selected, after execution of the script I get
Line1 \begin{environment} Line2 \end{environment} Line3 Line4 Line5
With "environment" being a placeholder to insert the environment name.
I have tried to write this script but no luck so far. The closest I have been to getting it to work is:
%SCRIPT txt = cursor.selectedText() editor.cut() editor.insertSnippet("\begin{%<environment%:id:1%>}\n"+txt+"\n\end{%<%:mirror,id:1%>}\n")</environment%:id:1%>
It kinda works, but the inserted text overwrites the text after the selection; i.e, I get: Line1 \begin{environment} Line2
\end{environmente4 Line5
Quite strange, isn't it?
Thanks in advance!
Biel
Log in to post a comment.
Hi!
Is there a way to write a script that surrounds the current selection with a \begin{environment}..\end{environment}?
That is, if the text I have is
Line1
Line2
Line3
Line4
Line5
And the second line is selected, after execution of the script I get
Line1
\begin{environment}
Line2
\end{environment}
Line3
Line4
Line5
With "environment" being a placeholder to insert the environment name.
I have tried to write this script but no luck so far. The closest I have been to getting it to work is:
%SCRIPT
txt = cursor.selectedText()
editor.cut()
editor.insertSnippet("\begin{%<environment%:id:1%>}\n"+txt+"\n\end{%<%:mirror,id:1%>}\n")</environment%:id:1%>
It kinda works, but the inserted text overwrites the text after the selection; i.e, I get:
Line1
\begin{environment}
Line2
\end{environmente4
Line5
Quite strange, isn't it?
Thanks in advance!
Biel