4

Coming from vim, if you place your cursor on the opening/closing bracket (block in vim speak) you can hit the % character to jump back and forth between the opening/closing bracket. Can we do the same in Texstudio? This would help a lot if I wanted to update the size of the brackets (e.g. to \Big). Or is there a similar command in TeXstudio that can perform the update action (i.e. changing ( some_text ) to \Big( some_text \Big) and vice versa) that you know of?

1

You can jump between matching braces, parentheses and brackets using Ctrl+Shift+p followed by j (all keys released before this last one). This seems to be a rough equivalent of Vim's % command.

3

There are several ways to achieve your goals. Depending on the situation different approaches can be reasonable.

Jumping between brackets

Simply jumping between brackets is possible using Idefix -> Parentheses -> Jump to Match. This is very generic, but you have to type the changes yourself.

Search using regular expessions

A simple way of replacing ( some_text ) with \Big( some_text \Big) would be to use Search/Replace with regular expressions. E.g. enter image description here

This comes in handy if you have to do a lot of replacements at a time. The disadvantage is that regular expressions cannot reasonably describe parentheses matching. I.e. it will fail if you have nested parentheses.

Use as Script Macro

Another approach would be to create a script macro (Maros -> Edit Macros...). Here's a basic example:

%SCRIPT
app.getManagedAction('main/edit2/parens/selectBracketInner').trigger()
text = cursor.selectedText()
app.getManagedAction('main/edit2/parens/selectBracketOuter').trigger()
newtext = '\\Big(' + text + '\\Big)'
cursor.replaceSelectedText(newtext)
cursor.clearSelection()

After creating the macro, you can change its shortcut at Options -> Shortcuts.

1
  • Thanks Tim, kudos for giving 3 options to solve the problem. Really appreciate that.
    – David KWH
    Mar 17 '17 at 5:08

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.