Community
    • Login

    [New Plugin] MultiReplace

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    93 Posts 12 Posters 100.8k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Thomas KnoefelT Online
      Thomas Knoefel @guy038
      last edited by Thomas Knoefel

      Hi @guy038,

      thanks for testing again! In case you’re curious, here’s roughly what the new loading threads in 6.2 do.

      As soon as the file list is known, a few worker threads start reading ahead: they open the files, read them, check for binary content and decode the text. The main thread takes the files in list order as soon as each one is ready, puts it into a hidden Scintilla document and searches it. So the hits and their order stay the same, but reading and searching now overlap.

      On a USB stick MultiReplace uses four threads by default. With a cold cache, as in your test, most of the time goes into waiting for your USB key, and that is where it helps: up to four files are read at the same time, and the search runs while the next ones are still loading.

      If you want to see what the threads bring on your key: with LoadThreads=0 in the [ReplaceInFiles] section of the INI file, every file is read on the main thread as before (see the README; it takes effect after restarting Notepad++).

      1 Reply Last reply Reply Quote 0
      • guy038G Online
        guy038
        last edited by guy038

        Hello, @thomas-knoefel and All,

        Indeed, changing the line :

        LoadThreads="auto"
        

        into this one :

        LoadThreads=0
        

        within the MultiReplace.ini file, the same list of files were found in 2 m ( instead of 1 m 13 s )


        Thus, I decided of an experiment, changing, on purpose, the LoadThreads line to :

        LoadThreads=8
        

        After restarting my computer and doing the test, the execution time was, this time, 1 m 28 s. However, verifying within the MultiReplace.ini file, I saw the line :

        LoadThreads="0"
        

        Is this the expected behavior, with the number 0 as a string ?

        Best Regards,

        guy038

        Thomas KnoefelT 1 Reply Last reply Reply Quote 1
        • Thomas KnoefelT Online
          Thomas Knoefel @guy038
          last edited by

          Hi guy038,

          interesting series of runs, thanks! Both runs without threads, the 2 m one and most likely the 1 m 28 s one too (see below), are slower than the 1 m 13 s with auto. So the threads do help on your key, even if cold runs vary quite a bit.

          Yes, the quotes are expected. LoadThreads is stored as text because it can also be "auto", and the quotes are removed when the file is read, so 0 and "0" mean the same.

          What changed your 8 back to 0 is something else: MultiReplace reads its INI file once at startup and, once its panel has been opened, writes all its settings back when Notepad++ closes. An edit made in the meantime is therefore overwritten on exit. So your 1 m 28 s run most likely still used LoadThreads=0.

          To test 8: change the line either in Notepad++ before opening MultiReplace, or with another editor while Notepad++ is closed. Then restart Notepad++, and the new value is used.

          Curiously, in my experience with other tools, four to six parallel threads were always the optimum.

          1 Reply Last reply Reply Quote 1
          • guy038G Online
            guy038
            last edited by

            Hi, @thomas-knoefel and All,

            For these Search Results : Search "Fi" (27 010 hits in 646 file(s)) [1 153 file(s) searched], I got, successively, using your valuable instructions :

            • 1 m 13 s 78, then 1 m 10 s 85 and finally 1 m 11 s 06 when LoadThreads="auto"

            • 1 m 25 s 78 and 1 m 26 s 39 when LoadThreads="0"

            • 1 m 09 s 54 and 1 m 09 s 55 when LoadThreads="8"

            So, the two tests with LoadThreads="8" seem very slightly better !?


            Note that :

            • From Laptop documentation, my processor is an Intel® Core™ i7-1165G7 2.80 Ghz (up to 4.7 GHz with Intel® Turbo Boost Technology ) 12 MB L3 cache, 4 cores 8 logical processors

            • From informations système, I saw for Processeur : 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz, 2803 MHz, 4 cœur(s), 8 processeur(s) logique(s)

            • Total installed RAM : 32 Gb

            This explain why I wanted to test with 8 threads. But, may be this assumption is not pertinent ! ?

            Best Regards,

            guy038

            Thomas KnoefelT 1 Reply Last reply Reply Quote 0
            • Thomas KnoefelT Online
              Thomas Knoefel @guy038
              last edited by

              Hi @guy038 ,

              to your question about the 8 logical processors: they don’t really matter here. The load threads do very little computing, they mostly wait for the key to deliver the next file. How many reads can usefully run at once depends on the drive, not on the CPU. That’s why auto picks the count by drive type: 4 for local drives like your key, 8 for network drives, where every file waits for the server, and 1 for hard disks, where parallel reads would just make the heads jump back and forth. On a key with a weaker controller, 8 could just as well be slower than 4. On yours it’s slightly faster, so feel free to keep it. 8 is also the maximum.

              One more thing: your first comparison showed 27 053 hits in the same 646 files, now it’s 27 010. Did anything change on the key in between?

              1 Reply Last reply Reply Quote 0
              • guy038G Online
                guy038
                last edited by guy038

                Hi, @thomas-knoefel,

                Thanks for your explanations. As you said :

                How many reads can usefully run at once depends on the drive, not on the CPU

                Thus, the LoadThreads="auto" option, in the MultiReplace.ini file, globally means :

                • 1 thread, in case of hard disks drives

                • 4 threads, in case of local drives

                • 8 threads, in case of network drives

                BTW, how SSD drives are considered ? Like the HD drives case, I suppose ?


                Regarding the differences in results of the search, I certainly deleted some files between the October, 27 and the October, 30. I can’t remember !

                In the meanwhile, on November 1, I deleted an 890x64 folder and created a new 899x64 folder on my USB key. Thus, today, running again the 3 search engines ( N++, MultiReplace and Search++ ) within my local N++ v8.9.9 install, I get, this time :

                Search "Fi" (25 921 hits in 642 file(s)) [1 151 file(s) searched] for all regex engines

                Best Regards,

                guy038

                Thomas KnoefelT 1 Reply Last reply Reply Quote 0
                • Thomas KnoefelT Online
                  Thomas Knoefel @guy038
                  last edited by

                  Hi @guy038,

                  your summary is right. By hard disks I meant the classic ones with spinning platters. SSDs get 4 threads, like your key. MultiReplace asks Windows whether a drive has a seek penalty, which only drives with moving read heads report. Those get 1 thread, CD/DVD drives too, and to be safe also USB disks that don’t answer that question.

                  And thanks for checking the hit counts, good to see all three engines agree.

                  Thomas KnoefelT 1 Reply Last reply Reply Quote 1
                  • Thomas KnoefelT Online
                    Thomas Knoefel @Thomas Knoefel
                    last edited by

                    MultiReplace 6.3 is out.

                    Its main new feature is Mark Replacements: you see in the text what Replace All changed and what was there before, and you can put back single replacements or a whole passage without undoing the rest. Find/Replace in Open Documents can now also be limited to the tabs you colored in Notepad++.

                    Download: Latest build

                    Key Features & Improvements

                    • Mark Replacements: Switch it on in the plugin menu, and after Replace All every replaced spot keeps a dotted underline and every deletion a small triangle. Hover a mark to see what was there before and which list entry made it.
                    • Revert Replacement: Select a passage and right-click it, or right-click a single mark, and only that passage gets its original text back while all other replacements stay. The same menu steps from change to change and selects the list entry.
                    • Tab Color Filter: Color the tabs you want in Notepad++, and Find/Replace in Open Documents can work on just those (Notepad++ 8.6.8 or later).
                    • Selection Scope Frame: In Selection scope, a light frame shows the searched area while you step through the matches.
                    • Column Highlight and Flow Tabs: Column highlight and sort state stay with their document when you switch tabs, and the Flow Tabs alignment is never saved or copied.
                    • Add into List: New entries go to the end of the list, or to the top if you prefer, and scrolling to them can be turned off.
                    • Other Plugins and Editor Themes: Marks stay visible and keep their colors next to plugins such as Columns++ and Search++, and the colors drawn into the text follow the editor theme.
                    • Fixes from the review: The whole plugin went through a code review, the fixes are listed in the release notes.
                    • Translations: Labels checked in all languages and scalings, and the Russian translation revised.

                    Mark Replacements

                    Mark Replacements

                    Revert Replacements in a Selected Passage

                    Tab Color Filter

                    Tab Color Filter

                    All changes are in the release notes.

                    Issues or suggestions: GitHub

                    Happy replacing!

                    1 Reply Last reply Reply Quote 2
                    • guy038G Online
                      guy038
                      last edited by guy038

                      Hello, @thomas-knoefel and All,

                      For example, in the screenshot below, using these different search-replacements, against the text below, I got these search results !

                      Notepad++ is a text editor and source code editor for use under Microsoft Windows. It support around 80 progamming languages with syntax highlighting and code folding. It allows working with multiple open files in a single window, thanks to its tabbed editing interface. Notepad++ is available under GPL and distributed as free software.
                      
                      
                      Notepad++ is a text editor and source code editor for use under Microsoft Windows.
                      bla
                      bla blah
                      It support around 80 progamming languages with syntax highlighting and code folding.
                      It allows working with multiple open files in a single window, thanks to its tabbed editing interface.
                      Notepad++ is available under GPL and distributed as free software.
                      

                      4ad8d13e-2730-4575-86c5-f73220450a7f-image.jpeg

                      But, after clicking, on the Next Search Result, The cursor went, successively, right after :

                      • The word 'Notepad++' only, in line 1
                      • The word 'Notepad++' only, in line 4
                      • The string 'aournd 80' only , in line 7
                      • The word 'multiple' only, in line 8
                      • The word 'Notepad++ only, in line 9
                      

                      Thus, if I’m not mistaken, I consider that the options Next Search Result and Previous Search Result should rather be labelled as Next Line Result and Previous Line Result ! May be, I’m miss something obvious !?

                      On the contrary, when I subsequently ran a Replace All operation, the Next Replacement and Previous Replacement options did go, in turn, to the different replacements, particularly in case of several replacements in a same line !


                      Now, in your documentation, within the Settings section, you said regarding the Find: Search from cursor position option :

                      Find: Search from cursor position — If checked and Wrap around is off, “Find All”, “Replace All”, and “Mark Matches” start from the current cursor position. Runs over open documents or files never start at the cursor. If unchecked, operations always process the entire defined scope.

                      So, if I understand you clearly, this behavior can be summarized in the table below :

                      
                      •================================•========================================•========================================•========================================•========================================•
                        In Settings\Search and Replace | Find: Search from cursor position  ON  | Find: Search from cursor position  OFF | Find: Search from cursor position  ON  | Find: Search from cursor position  OFF |
                                                       |                                        |                                        |                                        |                                        |
                                In MultiReplace dialog | Wrap around                        OFF | Wrap around                        OFF | Wrap around                        ON  | Wrap around                        ON  |
                      •================================•========================================•========================================•========================================•========================================•
                      | Find all                       |  From CURSOR location                  |  From START of file                    |  From START of file                    |  From START of file                    |
                      •--------------------------------•----------------------------------------•----------------------------------------•----------------------------------------•----------------------------------------•
                      | Find in Docs                   |  From START of files                   |  From START of files                   |  From START of files                   |  From START of files                   |
                      •--------------------------------•----------------------------------------•----------------------------------------•----------------------------------------•----------------------------------------•
                      | Find in Files                  |  From START of files                   |  From START of files                   |  From START of files                   |  From START of files                   |
                      •--------------------------------•----------------------------------------•----------------------------------------•----------------------------------------•----------------------------------------•
                      | Replace All                    |  From CURSOR location                  |  From START of file                    |  From START of file                    |  From START of file                    |
                      •--------------------------------•----------------------------------------•----------------------------------------•----------------------------------------•----------------------------------------•
                      | Replace in Docs                |  From START of files                   |  From START of files                   |  From START of files                   |  From START of files                   |
                      •--------------------------------•----------------------------------------•----------------------------------------•----------------------------------------•----------------------------------------•
                      | Replace in Files               |  From START of files                   |  From START of files                   |  From START of files                   |  From START of files                   |
                      •--------------------------------•----------------------------------------•----------------------------------------•----------------------------------------•----------------------------------------•
                      | Mark Matches                   |  From CURSOR location                  |  From START of file                    |  From START of file                    |  From START of file                    |
                      •================================•========================================•========================================•========================================•========================================•
                      

                      And I’m really confused because these two options seem to serve the same purpose ! I probably misunderstood the underlying logic behind these two options. Please enlighten me on this !

                      Best Regards,

                      guy038

                      Thomas KnoefelT 1 Reply Last reply Reply Quote 0
                      • Thomas KnoefelT Online
                        Thomas Knoefel @guy038
                        last edited by

                        Hi @guy038,

                        Hi guy,

                        … I’m trying to. First, thanks for testing 6.3 so quickly. You found a bug and the settings description was not clear enough.
                        Both points are fixed in this build.

                        • Next/Previous Search Result now stop at every hit of a line. A double-click jumps to the hit you click on, and F4 / Shift+F4 go on from there. After a new search, F4 starts with its hits.
                        • Your table is correct, the behavior stays as it is. The option is now called “Find All, Replace All, Mark: start at cursor”. A (?) next to it says when it applies: only with ‘Wrap around’ off, and not for runs over open documents or files. Does it make it clear or more confusing?

                        The two options don’t serve the same purpose, though. ‘Wrap around’ is for stepping from hit to hit. The other option decides where Find All, Replace All and Mark start. With the option on and ‘Wrap around’ off, they start at the cursor, like Replace All in Notepad++. Everyone can choose what suits them. By default, All means all, not from the cursor, whatever ‘Wrap around’ says.

                        If everything works for you, I will add this to 6.3.1.

                        1 Reply Last reply Reply Quote 0

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors