Disable brace highlight style in comments?

  • Hi, I’m new in Notepad++ and I’ve spent time seeking information about this in many forums. Finally, I had signed up here and I decided to ask. Well, it’s possible to dissable de style option: Brace highlight style but only in comments?

    I’ve been reading too how I can change the foreground to white on Selected text only, and I did what Claudia Frank said, and it worked perfectly! (here the post: https://notepad-plus-plus.org/community/topic/11039/foreground-options-for-selected-text)

    I hope there is some way to do it like there, with some command from Python Script, or something. Thanks you very much.



  • @albcntr

    in order to make this work we need to define that brace matching should use an indicator instead
    of a style and then enable/disable depending where we are.
    So something like

    comment_style_id = 1
    def callback_UPDATEUI(args):
        cur_pos = editor.getCurrentPos()
        if editor.getStyleAt(cur_pos) == comment_style_id or editor.getStyleAt(cur_pos-1) == comment_style_id:
            editor.braceBadLightIndicator(True, 8)
            editor.braceHighlightIndicator(True, 8)
            editor.braceBadLightIndicator(False, 8)
            editor.braceHighlightIndicator(False, 8)
    editor.callbackSync(callback_UPDATEUI, [SCINTILLANOTIFICATION.UPDATEUI])

    You need to check which style_id for comments is used by your lexer and change
    comment_style_id = 1 accordingly. If you use the default theme, check in stylers.xml
    otherwise see in the xml of your used theme (under themes directory).

    Btw. instead of pasting this into the standard startup.py I would recommend you create
    the user startup.py, simply by going to Plugins->Python Script->New Script
    and name it startup.py.


  • @Claudia-Frank

    Thanks so much, it works perfectly! Just like what I wanted. Ty ty.

    Fondest wishes

Log in to reply