Community
    • Login

    [New Plugin] MultiReplace

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    101 Posts 12 Posters 102.4k 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.
    • guy038G Offline
      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 Offline
        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
        • guy038G Offline
          guy038
          last edited by guy038

          Hi, @thomas-knoefel and All,

          First of all, I’d like to apologize for not congratulating you for this important release, in my previous post !


          I confirm that, with your new build, the search does go though all the matches and not only to the first hit of the lines. Nice !

          You said in your last post ::

          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.

          And in your documentation, you also said :

          Additionally, three navigation commands are available from the Plugins > MultiReplace menu and can be assigned to custom keyboard shortcuts via Settings > Shortcut Mapper > Plugin Commands:

          But adding the F4 and Shift + F4 shortcuts for your two commands, Next Search Results and Previous Search Results, via the Shortcut Mapper has the drawback of triggering the message CONFLICT FOUND

          Could you, like @coises, to insert these shortcuts within your code ? For example, with the Search++ plugin :

          • After you ran the Plugins > Search++ > Search... option, then the Ctrl + F shortcut opens the Search in Files window of the plugin

          • But if you switch back to the current document, a Ctrl + F shortcut opens the usual N++ Find dialog

          Using this way allows simultaneous shortcuts in both plugin and native N++. No need to use the Shortcut Mapper !


          You said :

          The option is now called “Find All, Replace All, Mark: start at cursor”. A (?) next to it says when it applies …

          In this new build, I did see the (?) indication which shows the calltip Only when 'Wrap around' is off and not for runs over open documents of files.

          However, I did not see the new mane of the option Find All, Replace All, Mark: start at cursor but still the old name Find: Search from cursor position

          Note that I downloaded the MultiReplace-Release-x64.zip archive. I don’t know if this matters !


          To my mind, the best is to always check this option in MultiReplace > Settings... > Search and Replace dialog. In this case :

          • When the Wrap around option is not checked, process goes from cursor position to end of file

          • When the Wrap around option is checked, process goes from the beginning of current file to its end


          You can verify this assumption, using the regex (?s)^xyz.+|^abc.+ against this text :

          This is
          a test
          abc
          with some text
          to see
          xyz
          if everything
          works properly
          
          • Place the caret at beginning of the 5th line to see

          • When the Wrap around option is OFF, a Replace All action, with Notepad++ or MultiReplace, deletes the third last lines ONLY

          • When the Wrap around option is ON, a Replace All action, with Notepad++ or MultiReplace, deletes everything from string abc in 1 replacement

          This clearly shows that the process goes from the very start of file when the Wrap around option is checked !

          If the process would have started from current position, then started again from beginning of file, once the end reached, we shoud have gotten the N++ message : Replace All: 2 occurrences were replaced in entire file ( first, using the (?s)^xyz.+ regex and then, using the (?s)^abc.+ regex )

          Best Regards,

          guy038

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

            Hi @guy038 ,

            Hi guy,

            thanks a lot, and no need to apologize! There have already been so many important releases ;-)

            The archive from GitHub Actions only contained MultiReplace.dll, so your old languages.ini still showed the old name. The text of the (?) is new, that’s why you already saw it in English. From now on languages.ini is part of the build. Here is the new build.

            Your test is right. Here MultiReplace deliberately differs from Notepad++: it was designed for mass replacement, and there it’s the more natural choice that All covers the whole text by default. The option is there for everyone who prefers the Notepad++ way.

            Good idea with F4, it’s in this build. F4 / Shift+F4 now work directly in the Search Results window, like in Search++, without the Shortcut Mapper, and the focus stays there. In the document, F4 keeps its Notepad++ meaning. If you assigned F4 / Shift+F4 to MultiReplace in the Shortcut Mapper, you can remove that again, which also clears the conflict.

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

              Hi, @thomas-knoefel and All,

              Thanks for this new build. The messages, in Settings, are indeed updated


              When I first opened the MultiReplace, I was surprised to not see the shortcuts F4 and Shift + F4 next to their labels !. Then I switched to the test file, below :

              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.
              

              And again, actions on F4 or Shift + F4 did not move the caret to next / previous move ?

              Then, I understood that these shortcuts are ONLY active when focus in on the MultiReplace - Seardh Results dialog !

              Then after a N++ restart, I verified that a N++ Find All operation of the Notepad\+\+ string allows the F4 and Shift + F4 shortcuts to act on, both, the Search results panel and the current document and move between the differents strings Notepad++ !

              However, I would totally understand that the possibility to allow these two shortcuts, within the current document of the Search results panel, could be rather difficult to implement !

              BTW, I noticed that it’s better to not use, simultaneously, a N++ Find all operation and a MultiReplace Find All one. Some weird behavior may occur, in this case !

              Best Regards,

              guy038

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

                Hi @guy038,

                thanks for testing again!

                Yes, F4 and Shift+F4 only work while the focus is in the MultiReplace Search Results window. That’s on purpose: in the editor, F4 and Shift+F4 belong to the Search results of Notepad++ itself. I don’t want to use a keyboard hook or any other trick to take them away from Notepad++, both results windows should work side by side. That’s also why there’s no F4 next to the menu entries.

                If you want to step through the MultiReplace results from the editor, give Next Search Result and Previous Search Result (Plugins > MultiReplace) a free shortcut in Settings > Shortcut Mapper > Plugin commands. If you prefer F4 and Shift+F4 for them, you first have to remove these keys from Next Search Result and Previous Search Result of Notepad++ in the Main menu tab, otherwise Notepad++ keeps them.

                About using the Find All of Notepad++ and of MultiReplace at the same time: what exactly did you see? A few steps to reproduce it would help me a lot.

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

                  Hi, @thomas-knoefel and All,

                  Finally, this strange behavior, which I had observed before, is not as strange as it seems. Indeed, it was your statement that helped me understand that, when you said :

                  That’s on purpose: in the editor, F4 and Shift+F4 belong to the Search results of Notepad++ itself.

                  So, for tests, I’ve included the same text file, below :

                  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.
                  

                  With your same searches within the MultiReplace plugin, as shown in this snapshot :

                  29199c80-f3b1-4fd1-be72-2596dd4894ce-image.jpeg

                  Then, I searched the string Notepad++ in Normal mode with the option Wrap whole word only against the test file and I got this snapshot :

                  34635b93-6e1b-47d3-b96f-457db4af3f50-image.jpeg


                  So far, here is what I’ve found out about the simultaneous use of the Find All command within native N++ and the MultiReplace plugin, where current document repesents the text file above :

                      •======================================================================•===============================================================•
                      |           When FOCUS => ON           When NO focus => OFF            |                     ACTION when pressing                      |
                      •----------------------------------------------------------------------•                                                               |
                      |  N++ Search Results | MultiReplace Search Results | Current Document |           The 'F4' key or the 'Shift + F4' shorcut            |
                      •=====================•=============================•==================•===============================================================•
                      |         OFF         |             ON              |        OFF       | Track occurrences in the 'MultiReplace Search Results' window |
                      •---------------------•-----------------------------•------------------•---------------------------------------------------------------•
                      |         OFF         |             OFF             |        ON        | Track occurrences in the 'Notepad++ Search Results'    window |
                      •=====================•=============================•==================•===============================================================•
                      |         ON          |             OFF             |        OFF       | Track occurrences in the 'Notepad++ Search Results'    window |
                      •---------------------•-----------------------------•------------------•---------------------------------------------------------------•
                      |         OFF         |             OFF             |        ON        | Track occurrences in the 'Notepad++ Search Results'    window |
                      •=====================•=============================•==================•===============================================================•
                  

                  As you can see, when the MultiReplace - Search results windows is visible but the focus is on the current document, a hit on the F4 or Shift + F4 shortcut goes through the N++ Search results hits ( and NOT through the MultiReplace Search results hits ) !

                  This fact seems coherent with your statement :

                  That’s on purpose: in the editor, F4 and Shift+F4 belong to the Search results of Notepad++ itself.

                  Best Regards,

                  guy038

                  1 Reply Last reply Reply Quote 1
                  • Alan KilbornA Offline
                    Alan Kilborn
                    last edited by

                    @guy038 said:

                    F4 and Shift+F4

                    I think you may be overthinking the situation. Maybe you think about it purely as a user, whereas I tend to think about it as a coder first.

                    When the MultiReplace Search Results has input focus, MultiReplace code is in control. It can do anything it wants with keyboard input, e.g. processing/consuming F4 and Shift+F4. Notepad++ processing and ShortcutMapper are not involved.

                    When other parts of Notepad++ have input focus, e.g. a Scintilla editor window, Notepad++'s Search results window, etc., then keyboard input processing follows normal Notepad++ behavior, usually per ShortcutMapper rules.

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

                      Hello, @alan-kilborn, @thomas-knoefel and all,

                      Alan, I’m replying now because I was out running some errands ! Of course, I’m not going to use these two similar features, simultaneously and for the same purpose

                      I suppose that I’ll use the Notepad++ Search results feature for simple searches / replacements and the MultiReplace Search results feature for simultaneous or complex searches and mass replacements !

                      BR

                      guy038

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

                        Thanks @guy038 for the table and @Alan-Kilborn for putting it in a nutshell. That’s exactly how it works.

                        About shipping shortcuts with the plugin: a plugin can define default keys for its menu commands, but it can’t take over keys Notepad++ already uses. If both have F4, Notepad++ wins. And there are only a few free combinations left. Ctrl+Alt is AltGr on many keyboard layouts, and any other key may already be taken by another plugin or by the user’s own mapping, and then only one of them works. So MultiReplace leaves the keys to the Shortcut Mapper.

                        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