Next: , Previous: , Up: Replace   [Contents][Index]


12.7.3 Replace Commands and Case

If the arguments to a replace command are in lower case, the command preserves case when it makes a replacement. Thus, the following command:

M-x replace-string RET foo RET bar RET

replaces a lower-case ‘foo’ with a lower case ‘bar’, ‘FOO’ with ‘BAR’, and ‘Foo’ with ‘Bar’. If upper-case letters are used in the second argument, they remain upper-case every time that argument 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 the variable case-replace is set to nil, replacement is done without case conversion. If case-fold-search is set to nil, case is significant in matching occurrences of ‘foo’ to replace; also, case conversion of the replacement string is not done.