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.

  • 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.). – Tim Hoffmann Mar 13 '16 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. – Nguyen Dung Mar 13 '16 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? – Tim Hoffmann Mar 15 '16 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. – Nguyen Dung Mar 15 '16 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? – Tim Hoffmann Mar 20 '16 at 15:41
  • Kindly check my answer here https://tex.stackexchange.com/a/453678/171689 You don't need to create a Macro, just edit the pre-defined one. Thanks. – Akhilesh Siddhanti Oct 03 '18 at 17:44

1 Answers1

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
naphaneal
  • 2,614