Old Pythonscript stopped working

  • Hello
    I had an old script from here for Pythonscript( witch was working fine till Notepad++ reached 7.7.
    I’m in need of this function once more and can’t get it to work.
    I’m not a huge Python guru so pls help.

    The original source of the script:


  • @Bérci-Róbert

    I don’t know about the script that stopped working, but I’d be inclined to do it this way instead; make it an on-demand thing (tied to a keycombo to run it):

    # -*- coding: utf-8 -*-
    from Npp import editor, notepad
    def main():
        matches = []
        if editor.getSelections() == 1 and not editor.getSelectionEmpty():
                editor.research(r'\Q' + editor.getSelText() + r'\E', lambda m: matches.append(1))
                matches = []
            notepad.messageBox('{} occurrence(s) of selected text'.format(len(matches)), '')

    Note: Definitely borrows heavily from the linked-to posting’s script.

  • @Alan-Kilborn
    I really liked that I only needed to double tap the variable names and see if it was used or just declared.
    Your’s works but can you work it with the double click highlights and no extra commands needed?

  • If you are using a newer npp version you need to update the python
    script plugin version as well as the newer npp version did introduce
    a newer and changed scintilla version which affected the notification structure.
    Depending on your currently used version of npp the installation procedure is different but if you are using the most recent version,
    you should be able to reinstall PS via the plugin admin.


  • @Ekopalypse
    Thanks. That did the trick.

Log in to reply