0

I'm using TeXstudio on Linux, and there is an option under the LaTeX/Font Styles menu to underline the selected text. For convenience, I set Alt + U as a shortcut so that I can quickly underline things.

The LaTeX/Font Styles menu with the "Underline - \underline" option highlighted. The shortcut Alt + U has been configured for this menu item.

I decided to change to soul's \ul instead of \underline in one of my documents because I don't want the underlined text to run into the margin (see this question). When I press Alt + U, I want TeXstudio to insert \ul{} (enclosing any selected text with the brackets) instead of \underline. How can I do this?

1 Answers1

1

You can make a macro. In the Macros menu, click Edit Macros..., then +Add. Enter the info like below (you can name it whatever you like): enter image description here

The %| means "put the cursor here".

If this does not overwrite the shortcut Alt+U, you may have to remove the default shortcut in Configure TeXstudio->Shortcuts->LaTeX->Font Styles->Underline.

mbert
  • 4,171
  • Works beautifully—thank you! Out of curiosity, do you know what the Abbreviation field does? And FYI, the Alt + U was a custom shortcut that I set up (it's not a default as of right now). – Ben Zelnick Aug 13 '22 at 15:19
  • 1
    It's a shortcut for the completer. You can read more about it here: https://htmlpreview.github.io/?https://github.com/texstudio-org/texstudio/master/utilities/manual/usermanual_en.html#SECTION33 – mbert Aug 16 '22 at 05:51