2

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

\begin{thm}

\end{thm}

(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.

2
  • 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... Jun 27 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... Jun 27 at 4:20
3

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.