This is not about new macros like \newcommand, \def and others.

This is not about autocompletion like using .cwl (in TexStudio)

This is also not about using shortcuts for predefined commands that are listed in the shortcuts sections.

None of the questions I could find here have answered this. I want to make a macro in TexStudio for various kinds of mathematics, but when I execute them I want to choose where the cursor goes.

For example, I know how to make a macro that would give me two modulus signs, so that when hitting ctrl + F2 (or the like) I get:

| |

Woopee, but now the cursor is to the right, and not actually in between the modulus signs.

( For an example of what I want to do, when you type Ctrl + Shift + m, such a command is executed, you get

$ $

With the cursor ready to insert the math inbetween. )

Do you guys reckon it's possible to do this?

1 Answer 1


Yes, see section 4.5.1 in Help --> User manual.

Specifically, the string %| in a macro decides where the cursor ends up, so if you go to Macros --> Edit macros, and make a new one where the LaTeX content is


then when hitting the corresponding shortcut, you will get two pipes with the cursor between them.

  • Perfect, you've just made my TeXing 1% faster :) :) Commented Mar 8, 2017 at 19:54

You must log in to answer this question.

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