Reputation: 2138
Is there any way to combine multiple search and replace statements into one for Notepad++.
I ask of Notepad++ to support regular expressions.
For eg: Supposed I have to change lot of values in a large code file which requires more that 20 find and replace actions. Can all these 20 actions be combined into one ?
I open to suggestions using other editors or implementations as well.
Upvotes: 2
Views: 3478
Reputation: 626
With Notepad++, the most direct way is to record a macro or series of macros, depending how much you will be reusing the search-replace set. For a one-off task it probably makes more sense doing it manually rather than recording the whole thing as a macro.
There is also the option of recording just one search-replace operation, then editing the macro in shortcuts.xml (more in this tread), copying the search-replace "algorithm" and editing each step. I used that for a simple string replacement with four actions, I suppose regex should work just as fine.
This is a simple one-step regex search-replace (replace everything in quotes with blank "") operation in my shortcuts.xml:
<Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
<Action type="3" message="1601" wParam="0" lParam="0" sParam='["].*["]' />
<Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
<Action type="3" message="1602" wParam="0" lParam="0" sParam='""' />
<Action type="3" message="1702" wParam="0" lParam="768" sParam="" />
<Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
Edit sParam in lines 2 and 4. Repeat as needed. I'd still suggest you record your own sample macro in case it produces something different, so you'll be on the sure side that it works with you.
Upvotes: 1