however looking up my questions using the usual suspects (Google, search function etc.) I could not find an answer/solution to the following task (potentially I don't know the proper name of the task I am looking for XD ):

In Texstudio I want to create my own macro/snippet for a figure environment, where the cursor is placed at a certain position to enter the filename. However I would like to have the same text filled in another position while I type (such as in the cmd+E environment snippet).


The /%<%> places my cursor at the desired position, but I am not able to figure out how to autofill this text in the label command while typing.

The second /%<%> just provides another cursor position which I can access manually.

I appreciate any help. So thanks in advance!

  • As a start you may have a look at the TeXstudio Usermanual - Section 4.5.3. It describes how to use JavaScript in order to script macros.
    – Markus
    Mar 29, 2015 at 16:13
  • %<foo%> just creates a placeholder. The cursor is placed at the first placeholder. Setting multiple cursors in a macro is not supported. Mar 29, 2015 at 19:12
  • Thanks so far, maybe I can figure out how to write a script. The manual is not very informative for a non IT person...
    – Stefan
    Apr 1, 2015 at 17:39
  • @TimHoffmann can you support this function, I think it is very useful.
    – noname1014
    Feb 13, 2016 at 19:45

2 Answers 2


For clarification

Multiple cursors are not supported. This would be something like


Mirrored placeholders are supported. This is an undocumented function and may change in the future without further notice.

  • I believe they are supported now, as well as multiple mirrors working fine. I guess it is worth to update the answer. Jan 23, 2017 at 14:52
  • No. The above example still does not work. Jan 24, 2017 at 21:16

I can see the problem. You are using a "/" which is only to indicate the image is in a subfolder. The code to positioning the cursor it's just conformed by %<%>. Creating a macro for inline math code, it look like

$ %<%> $

Inclusive, you can include text inside it, like a tag for reference:

$ %< tag %> $

If your macro has more than one cursor positions, with "ctrl+rightarrow" you will move the cursor to the next one position when you work with your macro. With "ctrl+leftarrow" you can reverse the position.

  • You are right, but this is not an answer. As Tim said on the comments, it is not possible to fill all placeholders typing only once.
    – Sigur
    Jan 28, 2016 at 20:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .