Emacs: Case Sensitivity in Text Search Commands
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.
- when emacs found
here, the replacement isdragon - when emacs found
Here, the replacement isDragon - when emacs found
HERE, the replacement isDRAGON.
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-replacetmeans smart. The case in replacement is in sync with the found text.nilmeans use the replace text as is.- Default to
t.
emacs and elisp regex
- Emacs: Regular Expression
- Emacs: List Matching Lines
- Emacs: Regular Expression Syntax
- Emacs: Regex Backslash in Command Prompt
- Emacs: Case Sensitivity in Text Search Commands
- Emacs: Insert Tab or Newline
- Emacs: Wildcards vs Regular Expression
- Elisp: Regular Expression
- Elisp: Regex Functions
- Elisp: Regex Backslash in Lisp Code
- Elisp: Case Sensitivity (case-fold-search)
- Elisp: Find Replace Text in Buffer
- Elisp: Match Data (Regex Result)
- Elisp: Unicode Escape Sequence
- Elisp: Convert Regex to Lisp Regex String
- Elisp: How to Test Regex
- Elisp: Regular Expression in Lisp Syntax, Rx (Package)
- Elisp: Regex Named Character Class and Syntax Table
- Emacs Regex vs Regex in Python, JavaScript, Java