Hi, @crafty-crafty, @ekopalypse, and All,
From the @ekopalypse macro solution, here is an similar solution which can be generalized to :
Any number of lines which are to be replaced, in the limit of 2,048 characters
Any number of lines which are to be inserted, during the replacement
But, first, let’s suppose that you simply have a specific line, repeated many times in your file, which must be replaced with a specific block of lines. Assuming that this line is named #Line# :
Open a new tab ( Ctrl+ N )
Type in the specific line #Line# line, followed with a line-break
Select the entire line #Line#, with its line-break
Open the Find dialog ( CTRL + F )
Select, if necessary, the Normal search mode
Leave all the other options unchecked
Click on the Find Next button ( Of course, no other occurrence is found, but it does not matter ! )
Close the Find dialog ( Esc )
Run the option Macro > Start Recording
Hit the F3 key ( Whatever an occurrence is found, or not, does not matter ! )
Hit the Ctrl + V shortcut ( The present contents of clipboard do not matter, too ! )
Run the option Macro > Stop Recording
Then, run the option Macro > Save Currently Recorded Macro...
Type in Replace Next Occurrence with Clipboard Contents, in the Name zone
Preferably, create a shortcut for this macro
Click on the OK button to valid the dialog
Create or select the block of lines, in any file, which must replace the #Line# line
Copy this block of lines in the clipboard ( Ctrl + C )
Now, open or select your specific file
If necessary, move to the very beginning of file ( Ctrl + Home )
Run the option Macro > Run a Macro Multiple Times...
Select the Replace Next Occurrence with Clipboard Contents macro
Tick the Run until the end of file option
Click on the Run button
Voila ;-))
Remark :
After finding all the occurrences of the specific line, a last search operation is carried on, without success. So, the last #Line# line is replaced by two or more consecutive contents of the clipboard. Thus, a last task has to be done :
Delete the few
extra blocks of text that have been
wrongly inserted, after the
last match !
As said above, this macro is not specific and can be used to insert any contents of the clipboard, in replacement of any specific text, even split on several lines, as long as the total amount of text is smaller than 2,048 characters ( Max size of the Find what: zone )
So, now that the macro Replace Next Occurrence with Clipboard Contents has been created, the road map becomes :
Create and select the text range which is to be replaced
Open the Find dialog ( CTRL + F )
Select, if necessary, the Normal search mode
Leave all the other options unchecked
Click on the Find Next button ( Whatever an occurrence of the range is found or not does not matter ! )
Close the Find dialog ( Esc )
Create and select the text range, in any file, even split on several lines, which will replace the initial range
Copy this text range in the clipboard ( Ctrl + C )
Now, open or select the specific file, where the replacements must occur
If necessary, move to the very beginning of the file ( Ctrl + Home )
Run the option Macro > Run a Macro Multiple Times...
Select the Replace Next Occurrence with Clipboard Contents macro
Tick the Run until the end of file option
Click on the Run button
Finally, delete the few extra range of text that have been wrongly inserted, after the last matched range !
Best Regards
guy038