If you highlight a brace / parenthesis / bracket in TexStudio, it will highlight the other brace. This is very useful.

I wonder if there is a related functionality that allows me to edit both braces at the same time, for example, change both braces to parentheses.

This will be a lot more convenient than editting the opening brace then hunting down the second brace.

  • 2
    this could be tricky in math, for there the concept of open and closed intervals is indicated with a parenthesis on one end and a square bracket on the other, for example $(a,b]$. but braces aren't as likely to be a problem. (i've become wary of automation trying to do too much ...) – barbara beeton Apr 7 '16 at 20:45

There's a TeXstudio function under

Idefix -> Parenthesis -> Select Inverting

(Default keyboard shortcut: Ctrl+Shift+P, followed by S)

Ensure your cursor is next to the parenthesis/bracket/brace that you are interested in (the pair will get highlighted appropriately), then activate the Select Inverting function. A mirror cursor will be placed in the corresponding bracket, and you can then make changes to both simultaneously.

For eg.

Changing (...) to [...]:


| improve this answer | |

I'm assuming you mean specifically for math expressions. You can always just create commands for each type of enclosure, e.g.


\delimp{XYZ} % (XYZ)
\delims{XYZ} % [XYZ]
\delimc{XYZ} % {XYZ}

This way you can just change the one character in the command to change the whole thing. (Optionally you could make these into size-sensitive delimiters via \left / \right.)

There are also some packages that can manage this sort of thing for you, to varying degrees. For example the commath package which includes, among other things, commands like \cbr for curly brackets, \sbr for square brackets, and even commands like \intco, \intoo, etc for intervals which are open/closed on either side (solving the problem barbara beeton brings up). However this package on the whole is not highly recommended since many of its commands are somewhat hacky or done better by other packages.

Another package you might like is the bropd package, which automatically adjusts delimiter size and style based on nesting of its \br command, e.g.


expands to an expression more like

\left[ \left(x-a\right)^2 + \left(y-b\right)^2 \right]^{1/2}.

(How do we actually typeset LaTeX on here?)

Finally, note that many of these commands might have issues for multi-line expressions. I know there is a package breqn that attempts to solve this problem, but I understand it is still experimental and has some compatibility issues.

| improve this answer | |
  • I was thinking about an IDE functionality, but this is quite clever as well. – Heisenberg Apr 8 '16 at 0:37
  • @Heisenberg well I believe TeXstudio actually has some functionality like that built in for enclosing expressions in delimiters or putting the ending delimiter in automatically when you type the left delimiter. But generally an approach like this is better programmatically. – wickles Apr 8 '16 at 0:44
  • TeXstudio does have the functionality, which motivates me to wonder if it also knows to change the closing delimiter when I edit the opening delimiter. So far it doesn't seem likely. – Heisenberg Apr 8 '16 at 0:46
  • @Heisenberg I'm sure they've considered that kind of functionality but if it doesn't exist that's probably intentional. I imagine there would be some adverse side effects, e.g. like barbara beeton mentioned. – wickles Apr 8 '16 at 0:49

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.