[New Plugin] MultiReplace
-
@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 :) -
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. -
@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.
-
@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
-
@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.
-
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.
-
@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 thetext
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…
-
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. -
@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!
-
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? -
@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.
-
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 calledMultiReplace
, how come I can’t find it? Oh, it’s because it is in theN
’s because the dubious decision was made to putNpp
on the front of its name…” -
@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.
-
@Thomas-Knoefel said in [New Plugin] MultiReplace:
@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.
Excellent, this should be the standard way of naming all plugins: so they can be found alphabetically ordered into the Plugin Menu too.
Thank you. -
Excellent, this should be the standard way of naming all plugins: so they can be found alphabetically ordered into the Plugin Menu too.
The plugin’s file name does not determine the display name in the install menu; that comes from the
"display-name"
property in the JSON manifest embedded in the Plugins Admin DLL.For example, selecting “F# Interactive” installs a module named
NPPFSIPlugin.dll
— with a pointless “-Plugin” suffix as well as prefix!
-
@Thomas-Knoefel said in [New Plugin] MultiReplace:
Changes are in the new RC5 build.
I realize that this is ‘release candidate’ stuff but…
I would guess from the size of the DLL in the “assets” that this is a “debug” build; you probably want to change this to a “release” build (forever more in all your releases of this plugin).
Should also consider a 32-bit build for our N++ family friends that use that one.
-
@Alan-Kilborn said in [New Plugin] MultiReplace:
Should also consider a 32-bit build for our N++ family friends that use that one.
All versions will ultimately be made available as “release” builds when plugin reaches 1.0.0.0 . I have updated RC5 now with all release builds. For all commits, I have an Action preparing the builds in the Git repository, which can be download here as well for the latest RC . (Kudos to @Michael-Vincent for his support with this.)
-
This post is deleted! -
It seems that regex replace with capture group ($1) doesn’t work. Would love to have this feature.
-
This post is deleted!