I'm trying to migrate to TeXstudio from a different editor, and was wondering whether it's possible to configure the following functionality:

If I write "\thm" (without the quotation marks) and hit Tab, I want "\thm" to be replaced by



(Preferably with the cursor already within the environment)

I've been playing around with the Macros editor in Texstudio, defining a macros with the trigger (also tried abbreviation) \thm, but this does not replace "\thm" by the actual LaTeX code (even though the editor is able to read the underlying code, at least judging by the output document).

Is this an option? I was previously using TeXShop for my typesetting, and this is (at the moment) the only feature I haven't been able to replicate.

With the current way Texstudio is set up, I need to start typing \begin, hit Tab, type thm, and then hit Return, which takes more keystrokes.

  • I think TexStudio does not like the \ in your trigger, maybe you can replace it by another character. At least with a german keyboard layout I can hit Alt Gr+Space and then Enter, this gives you \begin{*environment name*} content... \end{*environment name*} where *environment name* is selected so you can replace it instantaneous. I don't know whether there is a similar shortcut for other keyboard layouts... Commented Jun 27, 2021 at 4:15
  • Edit: It is Ctrl + Alt + Space. Maybe this is short enough for you. In addition to that you can use this for every environment, not only thm, but also for e.g. itemize, definition... Commented Jun 27, 2021 at 4:20

1 Answer 1


You can achieve that functionality by setting up a macro like this (%| specifies the position where the curser should be inserted)

enter image description here

Then you can use auto-completion to replace the abbreviation with the desired code-block:

enter image description here

enter image description here

  • Awesome, thank you so much!
    – Reveillark
    Commented Jul 3, 2021 at 21:25

You must log in to answer this question.

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