Converting a subversion repo to git, and setting up an authors file. I'm running query-replace-regexp on this text:


using this regexp:

^\(.*\)$ -> \1 = Some Lowercase Text Here <email@example.com>

When I execute the replacement, the replacement text is being capitalized like this, due to the case sensitive nature of replacements:


I understand what's happening, but is there a way to turn this off w/o writing a custom function (trivial, but still...)?

  • Tried this:Query replace regexp (default ^\(.*\)$ -> \1 = \,(substring "OneAmerica Former Employee <email.address@example.com>" 0)): but no dice. Seems the replacing operates on the text after it's created. Feb 24 '15 at 11:05

You can set the variable case-replace to nil before executing the command. Then you will get the following replacement

E001234 = Some Lowercase Text Here <email@example.com>

as expected. When case-replace is non-nil it preserves case in replacements, i.e. the case of the replacement matches that of the matched text.

Note, there is also the variable case-fold-search which also affects case in the match and as well as the replacement.

  • So sounds like I'd have to set that variable, run all my query-replace-regexp commands, then unset it? No way to toggle it as part of running query-replace-regexp? Feb 24 '15 at 14:39
  • Indeed. There is no why standard way to invoke query-replace-regexp with a particular choice of case matching option. Instead it is controlled via these variables. Feb 24 '15 at 17:13
  • @scottplumlee You can write a wrapper function that sets that variable in a let and then calls the query-replace-regexp. Let me know if you want me to elaborate that. Feb 25 '15 at 5:43
  • @kaushalmodi That's the method I am going to try, thanks. Feb 25 '15 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.