Subject: bug#10885: Replace expressions: enhance functionality when searching in filled paragraphs

From: Glenn Morris <[email-masked]>
Date: Sat, 25 Feb 2012 20:57:05 -0500

linuxfever wrote:

> Currently it seems that when trying to replace an expression comprising two
> words, say for example 'replace this', then the functions 'replace-string'
> or 'replace-regexp' fail to locate the expression when that is split along
> two lines in the text, i.e., in the above example when the word 'replace' is
> at the end of one line, and the word 'this' is at the beginning of the next
> one.

You can use query-replace-regexp for this.

Sample input:

This is text. This is text. This is text. This is text. Replace this.
This is text. This is text. This is text. This is text. This is text. Replace
this.
Replace                    this.

M-x query-replace-regexp RET \(replace\)\([ ^I^J]*\)\(this\) RET Done\2that RET

Output:

This is text. This is text. This is text. This is text. Done that.
This is text. This is text. This is text. This is text. This is text. Done
that.
Done                    that.