Regexp Replace Replace Query Replace
If the first argument of a replace command is all lower case, the
commands ignores case while searching for occurrences to
replace---provided case-fold-search
is non-nil
. If
case-fold-search
is set to nil
, case is always significant
in all searches.
In addition, when the newstring argument is all or partly lower case, replacement commands try to preserve the case pattern of each occurrence. Thus, the command
M-x replace-stringRET
fooRET
barRET
replaces a lower case `foo
' with a lower case `bar
', an
all-caps `FOO
' with `BAR
', and a capitalized `Foo
' with
`Bar
'. (These three alternatives---lower case, all caps, and
capitalized, are the only ones that replace-string
can
distinguish.)
If upper-case letters are used in the replacement string, they remain
upper case every time that text is inserted. If upper-case letters are
used in the first argument, the second argument is always substituted
exactly as given, with no case conversion. Likewise, if either
case-replace
or case-fold-search
is set to nil
,
replacement is done without case conversion.