Community
    • Login

    [New Plugin] MultiReplace

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    67 Posts 11 Posters 13.6k Views
    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
      Thomas Knoefel @Michael Vincent
      last edited by Thomas Knoefel

      @Michael-Vincent Thanks, I’ve seen it, and I’m going to commit them. However, the latest updates for codepage handling have not been committed yet. I still need to set up a VMware for Chinese Language settings in order to test DBCS. Once that is finished, I’ll upload the final updates.

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

        @Thomas-Knoefel These are the facts i fgured out. In Notepad++, when you ask about SCI_GETCODEPAGE, it’s always 0 for ANSI and 65001 for UTF8 you won’t encounter any other codepage. Asian codepages, like DBCS, only matter when you’re reading or writing files. So, these codepages won’t mess things up unless you’re working with files saved in these codepages. As for the Save and Load File feature of the plugin, which is designed for an internal store, it will always save in UTF8 format when handling CSV files.
        I think this fact will simplify the handling of codepages.

        1 Reply Last reply Reply Quote 0
        • Thomas KnoefelT
          Thomas Knoefel @Michael Vincent
          last edited by

          @Michael-Vincent said in [New Plugin] MultiReplace:

          I have a few more to add once those are merged.

          Thank you for your input! All requests are welcome. I can just learn from it.

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

            I have finished RC-2 version with fixed ANSI support and 32 Bit code compatibility. You can find it on Github.

            Vitalii DovganV 1 Reply Last reply Reply Quote 2
            • Vitalii DovganV
              Vitalii Dovgan @Thomas Knoefel
              last edited by

              Thank you! I like it!
              What probably may add more abilities to the plugin is: 1) to have a button that swaps the text between the Find What and Replace With fields; 2) to have checkboxes in the list to specify which Find-Replace pairs to activate and which to deactivate.

              Thomas KnoefelT 2 Replies Last reply Reply Quote 2
              • Thomas KnoefelT
                Thomas Knoefel @Vitalii Dovgan
                last edited by

                @Vitalii-Dovgan I will probably add both options before final release. Thanks for your input!

                1 Reply Last reply Reply Quote 2
                • Thomas KnoefelT
                  Thomas Knoefel @Vitalii Dovgan
                  last edited by Thomas Knoefel

                  @Vitalii-Dovgan said in [New Plugin] MultiReplace:

                  What probably may add more abilities to the plugin is: 1) to have a button that swaps the text between the Find What and Replace With fields; 2) to have checkboxes in the list to specify which Find-Replace pairs to activate and which to deactivate.

                  RC-3 has been finished!

                  This update includes the following new features:

                  • Set individual or multiple list entries active or inactive by clicking the select button.

                  • The Space key enables you to select or unselect multiple highlighted entries at once. You can also select or unselect all by clicking at the Header.

                  • The selection status will be saved in CSV

                  • Swap Button for switching Find and Replace text.

                  The Readme and Screenshot has been updated. Feel free for testing it! You can find it on Github.

                  Vitalii DovganV 1 Reply Last reply Reply Quote 3
                  • Vitalii DovganV
                    Vitalii Dovgan @Thomas Knoefel
                    last edited by

                    @Thomas-Knoefel
                    Thank you!
                    For some reason I had an impression that the Find-Replace list, as well as the histories of the “Find what” and “Replace with” are automatically saved when Notepad++ exits… Could this be added? Probably the plugin may store this information under the PLUGINSCONFIGDIR folder as e.g. “NppMultiReplace.csv” and “NppMultiReplace.ini”
                    Well, I realize this also implies some settings where one could enable/disable saving of the Find-Replace list and the “Find what” and “Replace with” histories :)

                    Vitalii DovganV Thomas KnoefelT 3 Replies Last reply Reply Quote 2
                    • Vitalii DovganV
                      Vitalii Dovgan @Vitalii Dovgan
                      last edited by Vitalii Dovgan

                      As a side note, I noticed that the LocationNavigate plugin crashes on huge number of replacements, either when a lot of replacements have been done or when the replacement are undoed. (For example, I reproduced it while replacing “CMD” with “CMD” inside of “NppExecEngine.cpp” - 1149 occurrences).
                      It seems to be a problem of the LocationNavigate plugin itself, but it was worth mentioning anyway.
                      As maybe an idea for the future version of the MultiReplace plugin, the replacements performance could be dramatically increased if the whole text was read from Scintilla into a memory buffer first, then all the replacements were done with the text in the memory buffer, and finally the resulting text was put into Scintilla. That would probably fix the problem with the LocationNavigate plugin as well.

                      Thomas KnoefelT 1 Reply Last reply Reply Quote 3
                      • Thomas KnoefelT
                        Thomas Knoefel @Vitalii Dovgan
                        last edited by

                        @Vitalii-Dovgan said in [New Plugin] MultiReplace:

                        For some reason I had an impression that the Find-Replace list, as well as the histories of the “Find what” and “Replace with” are automatically saved when Notepad++ exits… Could this be added?

                        I had this already in mind when I started implementation but forgot about it. Yes, I will implement this.

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

                          @Vitalii-Dovgan said in [New Plugin] MultiReplace:

                          As maybe an idea for the future version of the MultiReplace plugin, the replacements performance could be dramatically increased

                          I conducted performance tests yesterday and observed a noticeable difference in performance. There is still room for improvement, but I can confirm that there were no crashes. Specifically, the performance of CopyToClipboard is lacking. However, I will prioritize addressing this in the next release.

                          I’m considering another feature that could be quite helpful and compensate for the absence of Find capabilities. Next to the Mark button, it might be possible to add up and down keys (similar to those found in NPP Find). After marking, it would be useful to navigate to the marked positions, especially in large files. From a technical standpoint, I’m working on a concept, but I’m not yet convinced about the final result. It would be easy to store all marked positions and sort them. However, if any changes are made to the file, it cannot be guaranteed that these positions are still correct or that the marked text still exists. This presents a limitation. After marking all strings, the plugin should detect any changes. In such cases, the up and down navigation should be disabled. Only by marking all strings again would these buttons be enabled. I haven’t researched Scintilla yet, particularly how to detect changes after a specific moment, and perhaps this would need to be monitored through WM_TIMER. However, I’m still unsure if this limitation is acceptable. There might be other ways to solve it that I haven’t explored yet

                          Mark OlsonM 1 Reply Last reply Reply Quote 0
                          • Thomas KnoefelT
                            Thomas Knoefel @Vitalii Dovgan
                            last edited by

                            @Vitalii-Dovgan said in [New Plugin] MultiReplace:

                            For some reason I had an impression that the Find-Replace list, as well as the histories of the “Find what” and “Replace with” are automatically saved when Notepad++ exits…

                            The INI support has been integrated. All settings of List, History, and Options are stored in the INI and will be reopened when loading the Plugin.

                            Due to the addition of some extra features that I am still working on, I will release RC4 a bit later.

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

                              RC-4 has been finished, featuring:

                              • New Find and Replace functionality in 2Buttons Mode.
                              • Sort lists by clicking on the header.

                              Several optimizations and fixes, including:

                              • Update of INI Unicode support.
                              • Updates of Codepage assignments.
                              • Clipboard copy performance optimization.
                              • and a lot of other adjustments

                              Feel free to test it! You can find it on Github.

                              1 Reply Last reply Reply Quote 2
                              • Mark OlsonM
                                Mark Olson @Thomas Knoefel
                                last edited by

                                @Thomas-Knoefel said in [New Plugin] MultiReplace:

                                After marking all strings, the plugin should detect any changes.

                                Pretty sure the way to check if a file has been modified is to subscribed to the SCN_MODIFIED notification and check if the text field of the notification object has been populated (since the notification can fire if there are changes other than text changes).

                                But of course your plugin changes the text itself, and so you need some way to distinguish from your plugin’s changes… Hmm…

                                Thomas KnoefelT 1 Reply Last reply Reply Quote 2
                                • Mark OlsonM
                                  Mark Olson
                                  last edited by Mark Olson

                                  Actually, there’s an even easier way that I just remembered to determine if a SCN_MODIFIED notification entails text changing:
                                  check if (notification.modificationType & 3) != 0

                                  This works because 3 = SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT, and all text modifications trigger a notification with one of those flags set.

                                  1 Reply Last reply Reply Quote 2
                                  • Thomas KnoefelT
                                    Thomas Knoefel @Mark Olson
                                    last edited by

                                    @Mark-Olson said in [New Plugin] MultiReplace:

                                    But of course your plugin changes the text itself, and so you need some way to distinguish from your plugin’s changes… Hmm…

                                    Indeed, this can quickly turn into a complex issue. That’s why I’ve added a regular Find feature, which wasn’t originally planned but serves the same purpose I intended to implement. The advantage here is that it’s easier to maintain and isn’t solely limited to locating positions within Marked Strings. Sometimes, exploring alternative approaches proves to be simpler… thanks for your support; this will answer the questions I was looking for!

                                    1 Reply Last reply Reply Quote 2
                                    • Vitalii DovganV
                                      Vitalii Dovgan
                                      last edited by

                                      A tiny thing that confuses me with each update of the plugin: it’s physical name is “NppMultiReplace.dll” and, correspondingly, its folder name is “NppMultiReplace”, and in the same time the plugin identifies itself as “MultiReplace” (without “Npp”) in the main menu.
                                      Maybe the same name in both places would be better?

                                      Michael VincentM Thomas KnoefelT 2 Replies Last reply Reply Quote 1
                                      • Michael VincentM
                                        Michael Vincent @Vitalii Dovgan
                                        last edited by

                                        @Vitalii-Dovgan said in [New Plugin] MultiReplace:

                                        Maybe the same name in both places would be better?

                                        Agree. Drop the “Npp” - it’s obvious the plugin is for Notepad++. You can name the repo “npp…” if you like, but the plugin DLL itself (and thus folder) should drop the “Npp” prefix.

                                        Cheers.

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

                                          Leading off a plugin name with Npp is a sure way to cause it to get visually lost to someone looking for it in the PluginsAdmin list: “Damn, I know it is called MultiReplace, how come I can’t find it? Oh, it’s because it is in the N’s because the dubious decision was made to put Npp on the front of its name…”

                                          1 Reply Last reply Reply Quote 4
                                          • Thomas KnoefelT
                                            Thomas Knoefel @Vitalii Dovgan
                                            last edited by

                                            @Vitalii-Dovgan said in [New Plugin] MultiReplace:

                                            Maybe the same name in both places would be better?

                                            Good point, consistency matters. I’ve renamed project and files to ‘MultiReplace’ and dropped the ‘Npp’ prefix. Changes are in the new RC5 build.

                                            wonkawillyW Alan KilbornA 2 Replies Last reply Reply Quote 5
                                            • First post
                                              Last post
                                            The Community of users of the Notepad++ text editor.
                                            Powered by NodeBB | Contributors