emacs
Use C-q C-j to specify a newline in the pattern to match or replace with. Plain text and regexp are supported, either all at once or in query mode (get confirmation for each match).
The functions you want are
replace-string
query-replace-string
replace-regexp
query-replace-regexp
and they can all be invoked with M-x <function name>. Some have default bindings.
Use C-h f <function-name> to learn what binding is currently assigned to any function.
To select a block from the text to use
- More the point to one end of the block. Hit
C-<space>.
- Move the point to the other end. Hit
C-w which will yank the whole block then C-y to return the yanked block or invoke copy-region-as-kill.
M-x <function> then C-y to paste the block into the search space. Newlines are handled naturally.
- proceed as normal.