Skip to content

need an option to ignore brackets in comments #4066

@mathteacher75

Description

@mathteacher75

I often use comments to switch between two commands with the same arguments. In the following code, the syntax highlighting detects that the opening bracket is in %\secondcommand{, instead of \firstcommand{. How to make syntax highlighting ignore brackets in comments, so that it can detect pairs of brackets just like the compiler does ?

Image

Ignoring all comments for syntax highlighting could be an acceptable solution to me, even if it unactivate %TODO detection or other features. How to do that ?

Any help would be appreciated.

Activity

sunderme

sunderme commented on May 9, 2025

@sunderme
Member

there is no good way of achieving this.
The bracket matching is done with regex which does not easily allow for comment detection.
You can set up your own definition though, see https://texstudio-org.github.io/background.html#writing-your-own-language-definitions

sunderme

sunderme commented on May 9, 2025

@sunderme
Member

You could also move the opening brace to the next line...

mathteacher75

mathteacher75 commented on May 10, 2025

@mathteacher75
Author

You could also move the opening brace to the next line...

@sunderme This approach is impossible, since i have nested commands, of which several might be commented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sunderme@mathteacher75

        Issue actions

          need an option to ignore brackets in comments · Issue #4066 · texstudio-org/texstudio