In general I would like TeXStudio to close my brackets (including {}), but there is always the same problem while using this feature (especially in mathmode): Assuming I want to write something like $\{\hfill\}$ TeXStudio is always ignoring the second \ (because it is overwriting it in the process of typing) and it produces the code $\{\hfill}$. There is obviously a very easy workaround to this problem (by always putting a space after having opened a bracket), but I wonder if there is a way to prevent the second \ to be overwritten (in ALL cases), because I simply do not have any use for this functionality and it is always getting into my workflow and hindering me. I already scrolled through the properties (also the advanced properties), but I haven't found anything useful yet (apart from deactivating the whole "bracket-closing-feature" in auto-completion).

I'd be very thankful for any suggestions.

  • 1
    \text requires an argument, so it is expecting the next character to be a {. since you have \ it is probably being thrown away, with an error message in the log. i haven't any idea, though, how to implement insertion of the {...} in texstudio to provide for adding an argument. Jul 30 '15 at 16:26
  • Thanks for your reply. Maybe my question was a little off (the \text in my question was just a place holder for any command) - I don't want TeX to insert the {...}, I just don't want it to overwrite the \ when typing something like \{\hfill\}. The problem is that \{\hfill\} automatically becomes something like \{\hfill} which is unfortunate because it is not what I intended to type ;) Jul 31 '15 at 10:11

There is currently litte you can do about it. The only possibilities are to either type the complete expression, or to remove the placeholder of the closing bracket (Ctrl + Shift + K).

The most important rule for automatic bracket insertion is that it should be transparent to continuous typing. E.g. if you type the sequence \{sometext\}, the text in the editor should be exactly the same.

When you type a backslash in sometext, at that moment you are in an ambiguous state. TXS cannot know if you just want to continue by typing the closing brace or if you want to type another command. So the best assumption we can make is the former. One can only later recover from that ambiguity. Currently TXS uses the latest possible time to recover; i.e. you continue typing, insert a backslash and a closing brace which will be overwritten. So recovering from the assumption due to the ambiguity does only work if you really do type the complete sequence.

In prinicple, it would be possible to recover earlier. As soon as you type the h in your example, \{\|} could become \{\h|\} by reinserting the overwritten part of the delimiter (| marking the position of the cursor). But that would require additional internal logic, which is currently not implemented.

  • Thank you so much. Your answer is exactly what I needed to get some relief ;) Aug 2 '15 at 13:50

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.