3

I want to set up a macro in TeXstudio for math mode which displays $*$ and places the cursor at position *. So far I have tried using $%|$ but upon triggering, this macro does not allow text insertion at the placeholder.

EDIT: The method above works fine if the macro shortcut is set to the default Shift+F1. However, changing the shortcut to another combination, as I would like to do, seems to be the cause of the problem.

6
  • What do you mean by "upon triggering, this macro does not allow text insertion at the placeholder". The macro does insert the dollars an places the cursor in between (Note: %| does not insert a placeholder but positions the cursor). After that, the macro is done. You can now regularly insert text at the cursor position by all editing actions (typing, pasting, etc.). Commented Mar 13, 2016 at 20:51
  • The macro does indeed place the cursor at the prescribed position, but after that for some reason I cannot resume typing inside the math mode. Commented Mar 13, 2016 at 21:09
  • That does not really make sense to me. Is the focus on the editor (cursor blinking)? Can you move the cursor with the arrow keys? Does typing work again if you click with the mouse on the cursor position? Commented Mar 15, 2016 at 21:33
  • The cursor is not blinking and I cannot move it with the arrow keys either. Typing does work again if I click with the mouse on the cursor position, but I would like to avoid this manual adjustment. Commented Mar 15, 2016 at 21:46
  • It seems that somehow the focus is going somewhere else. a) Can you see which GUI element has focus afterwards? b) Does it happen regardless of how you trigger the macro (shortcut or menu). c) Does it happen with other macros as well? Commented Mar 20, 2016 at 15:41

1 Answer 1

5

According to the answer here and section 4.5.1 Text macros of the TeXstudio manual

$*%|$

does the trick.

When defining macros in TeXstudio, %| (spoken: percent pipe) tells the IDE where to put the cursor, after the macro is triggered. Macros in TeXstudio are defined in

Macros -> Edit Macros
2
  • Welcome to TeX.SX! Can you be a bit more precise?
    – egreg
    Commented Mar 13, 2016 at 20:16
  • @egreg mea culpa. I hope it's more precise now.
    – naphaneal
    Commented Mar 13, 2016 at 20:28

You must log in to answer this question.

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