Emacs: Case Sensitivity in Text Search Commands

By Xah Lee. Date: . Last updated: .

Case Sensitivity in Text Search Commands

By default, search commands are Case-Insensitive.

Alt+x toggle-case-fold-search

toggles the variable case-fold-search [see ELisp: Case Sensitivity (case-fold-search)]

When true, it is Case-Insensitive.

💡 TIP: remember to toggle it back when you are done.

Case Sensitivity in Replacement

By default, the case of the replaced text is smartly dependent on the matched text.

For example, suppose your search string is here, and your replacement string is dragon.

If you want the letter case of your replacement string be exactly as you have it, you need to set the variable case-replace to nil. You can do so by Alt+x set-variable.

Case Sensitivity for query-replace

variable case-replace

control Case Sensitivity in replacement, for the command query-replace

  • t means smart. The case in replacement is in sync with the found text.
  • nil means use the replace text as is.
  • Default to t.

Emacs: Case Sensitivity in Text Search

Emacs, Regular Expression in Interactive Commands