Is it possible to use autocomplete in creating a macro script for Texstudio. The reason I need this is that I want to see what classes with what features can I reach when creating an script. For a simple instance, I have read a line using the following code(part of the code)

 var str = editor.text(linenumber);

Now I need to search inside "str" string. In a usual IDE you can find the proper function by using the autocomplete of that IDE. Such an autocomplete will find fucntion like


Is it a way to be informed of such functions like "search" when writing scripts for Texstudio?

  • 1
    I think your question is not clear at all. Can you please put a MWE and show what you need to exactly do in that script? – Diaa Aug 15 '16 at 23:06
  • For instance, one of the functions that can be reached in the script section of Texstudio is editor.search(..). I want to see if I can find this function by any kind of autocompletion. – Hamid Aug 15 '16 at 23:19
  • I edited the question to be more comprehensible. – Hamid Aug 15 '16 at 23:50

There is no autocompletion in the macro editor. This would require a complex code model of the scripting language. Neither do we have the resources to work on that, nor is it in the focus of the editor. TeXstudio is primarily a LaTeX editor with scripting support, not a script editor.

As a workaround, you may inspect an object at run-time. Here is an example for a method that writes all properties of an object to a new editor tab (based on the code sample for introspection):

function write_properties(obj) {
    newEditor = documentManager.currentDocument.editorView.editor;   //access the newly created document
    newEditor.setText(Object.getOwnPropertyNames(obj).join("\n"));   //print the properties

obj = editor;                                                    //object to show (e.g. the current editor)
  • However, there should be some kind of the IDE with which I can reach the classes and methods as yourself write the program. I have tried Webstorm but I'm not sure how to configure it to have the app editor cursor classes – Hamid Aug 16 '16 at 17:20
  • Likely not. The script interfaces the C++/Qt classes of TXS at runtime. That means these classes are not written down anywhere as JavaScript code. I strongly doubt that any IDE is able to figure that out and reinterpret the C++/Qt classes to Javascript classes by static code analysis. – Tim Hoffmann Aug 17 '16 at 20:55
  • What about a better documentation of the methods which I can reach via scripting. Is there any other documentation besides the manual? I have written several working scripts. However, coding in this scripts seems to be very confusing and also very wanted. – Hamid Aug 17 '16 at 21:05
  • There is no further documentation and that's on purpose (apart from the fact that we wouldn't have time for it). The methods are directly hooked to the internal C++ code. If we change something in the C++ code the scripting will change as well and that would break your scripts. The documented methods are methods we're trying to keep stable to provide a stable scripting API. Exposing everything would essentially mean that we couldn't change any internals without the risk of breaking scripts. We don't want that. – Tim Hoffmann Aug 19 '16 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.