latexqtscripttexstudio

TeXstudio macro script : how to move the cursor to specified position?


For example, I want to write the following macro in script in TeXstudio(using QtScript):

%SCRIPT   
editor.write("\\textcolor{red}{}")

After invoking this macro, I want the cursor to move into the second pair of curly braces automatically. How can I modify my code to achieve the desired effect?


Solution

  • %SCRIPT
    txt = "\\textcolor{red}{}"
    cursor.insertText(txt)
    cursor.movePosition(1,cursorEnums.Left)