@MayTheCatgirl said:
I tried using the following expression with “. matches newline” enabled and it finds the code block:
[beginning of code].+?[end of code]
However Notepad++'s find and replace does not support multiline find and replace
I’m wondering what you mean by “does not support multiline find and replace.” I think you must mean that you can’t easily enter a replace expression that contains multiple lines.
and when I use it this way to paste the 100-line block of code where I want it, it messes up the formatting and cuts off the last few lines.
There are a couple possible problems. I believe there is a character limit (I don’t recall what it is) to how much you can put in the Replace box.
But also… are you considering that you can’t just blindly copy a block of code into that box, because some characters have special meanings? In particular, backslashes, parentheses, and depending on the context, dollar signs, question marks and colons, have special meanings and must be escaped.
I assume you are substituting the original content, so you’re using something like:
Find: OLDPREFIX(.*?)OLDSUFFIX
Replace: NEWPREFIX$1NEWSUFFIX
to do it? Or is the replacement content exactly the same every time, using no part of the original content?
I’d love to just use the default Notepad++ one for this as its “find in files” feature is a lot more helpful than requiring me to open all 300 files I want to search through but it seems that is not an option.
It can probably be done. It might have to be done in a couple steps instead of just one, if the replacement expression has too many characters to put in the box all at once.