From: Richard M. Stallman Date: Sun, 24 Nov 2002 19:07:46 +0000 (+0000) Subject: (Unconditional Replace): Explain how to replace two strings X-Git-Tag: ttn-vms-21-2-B4~12278 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=46b1e9bb80473fe5a3190900ec358ff7a4e9978f;p=emacs.git (Unconditional Replace): Explain how to replace two strings each with the other. --- diff --git a/man/search.texi b/man/search.texi index ea2b461e276..a9d5b5e9ba5 100644 --- a/man/search.texi +++ b/man/search.texi @@ -845,6 +845,18 @@ C-@key{SPC}} to move back there. A numeric argument restricts replacement to matches that are surrounded by word boundaries. The argument's value doesn't matter. + What if you want to exchange @samp{x} and @samp{y}: replace every @samp{x} with a @samp{y} and vice versa? You can do it this way: + +@example +M-x query-replace @key{RET} x @key{RET} @@TEMP@@ @key{RET} +M-x query-replace @key{RET} y @key{RET} x @key{RET} +M-x query-replace @key{RET} @@TEMP@@ @key{RET} y @key{RET} +@end example + +@noindent +This works provided the string @samp{@@TEMP@@} does not appear +in your text. + @node Regexp Replace, Replacement and Case, Unconditional Replace, Replace @subsection Regexp Replacement