How can I do a case-sensitive search in Emacs?
Asked Answered
M

3

25

Is there a shortcut? Ctrl + S gives I-search:, and that is case-insensitive.

Montpellier answered 22/7, 2012 at 17:38 Comment(0)
M
42

You press M-c after you run search.

This will set the case-sensitive flag.

More generally, you can do: C-s C-h b to see all keybindings active during search, in isearch-mode-map.

Mcmorris answered 22/7, 2012 at 17:39 Comment(0)
G
14

In addition to M-c mentioned by alinsoar, entering a capital letter as part of your search string will cause the search to be case-sensitive.

Gerson answered 22/7, 2012 at 20:42 Comment(2)
should capital letter entered as the first character?Stemma
Not much use if you're searching for a lower-case string... :)Subside
R
0

To make case-sensitive search the default, add this to your startup file (e.g. ~/.emacs), or evaluate it during your Emacs session:

(setq case-fold-search nil)

To set it back to the normal case-insensitive behavior (which can also be case-sensitive when a capital letter is used in the search string as @Tyler noted earlier), use:

(setq case-fold-search t)

More info: https://www.gnu.org/software/emacs/manual/html_node/efaq/Controlling-case-sensitivity.html

Reptilian answered 28/7 at 19:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.