The Stack Overflow podcast is back! Listen to an interview with our new CEO.
13

(customize-set-variable case-fold-search nil) Or bind that variable (option) in your own command that is otherwise just a wrapper around query-replace. This has the advantage that it doesn't change the variable value for general use, outside of query-replacing. See also variable case-replace, which controls case for the replacement text. See also C-h f ...


6

How about using keyboard macros: <f3> -- start recording C-M-s \b[A-Z]\{2,\}\b RET -- find the next word of only upper-case letters and at least 2 letters. M--M-c -- Call capitalize-word on the word before point M-0<f4> -- Stop recording and run the macro repeatedly until error n.b. If that's catching non-upper-case words as well, you'd need to set ...


6

Retaining the cases on replacing By default, emacs retains the cases when replacing. From the emacs manual, When the newstring argument is all or partly lower case, replacement commands try to preserve the case pattern of each occurrence. Thus, the command M-x replace-string <RET> foo <RET> bar <RET> replaces a lower case foo ...


6

What to do You can customize the variable evil-ex-search-case to tell it what you want evil to do when searching. Here's the docstring: evil-ex-search-case is a variable defined in evil-vars.el. Its value is smart Documentation: The case behaviour of the search command. Smart case means that the pattern is case sensitive if and only if ...


6

You can temporarily bind case-fold-search using let: (let ((case-fold-search nil)) (looking-at "[\n\t ]*[A-Z]")) Also, I changed your regexp for matching whitespace and newlines -- a ] was missing and you don't need the backslash before the space. Here is the corrected code, also incorporating Zorgoth's edits below. (defun capitalize-unless-org-heading ...


3

You can toggle case sensitivity during incremental search by typing M-c. Documentation here.


3

Short and narrow answer You need to set the variable case-fold-search to nil in order to have case sensitive search. So: put this somewhere in your init file: (setq case-fold-search nil) See the manual node on Searching and Case for more details. Some background explanation spacemacs relies heavily on evil, which emulates Vim. In general, you should ...


2

Be aware that there are some mistakes in that code. I don't know if \* means anything at all in this context (\\* does). You also need to escape + with two backslashes as that has a meaning in emacs regexps. And there is a * at the beginning of a string that I presume was intended to be after a space. Apart from that, the answer above answers the main ...


2

What is wrong with my use of case-fold-search? You've set it to t instead of nil. case-fold-search is a variable defined in C source code. [...] Non-nil if searches and matches should ignore case. Hence nil means case-sensitive, and anything else means case-insensitive.


1

Customize option read-buffer-completion-ignore-case to non-nil. C-h v read-buffer-completion-ignore-case tells you: read-buffer-completion-ignore-case is a variable defined in C source code. Its value is nil Documentation: Non-nil means completion ignores case when reading a buffer name. You can customize this variable. This ...


1

Note, that I assume that isearch-toggle-case-fold is not supposed to be run outside of isearch-mode. Cause of the effect: The highlighting belongs to the overlay stored in variable isearch-overlay generated or moved by function isearch-highlight. isearch-highlight is called in isearch-update which is called in isearch-toggle-case-fold generated by isearch-...


1

You can easily do what you want with library Highlight (highlight.el. Just set or bind case-fold-search to t and call any of the regexp-highlighting functions: hlt-highlight-regexp-to-end - Matches from point to point-max. hlt-highlight-regexp-region - Matches within the active region (or full buffer if not active). hlt-highlight-regexp-groups-region - ...


1

The following change to xx-replace-regexp-and-return solves the problem: (defun xx-replace-regexp-and-return (from to) (let ((case-fold-search nil))) (save-excursion (while (re-search-forward from nil t) (replace-match to 1)))) The only change needed was to add (let ((case-fold-search nil))). This comes from the documentation of the ...


1

If you want to take @phils answer and wrap it in a command that handles the region, here's one approach: (defun caps-to-title-case (start end) "Convert words in CAPS to Title Case in the current region or buffer." (interactive (if (use-region-p) (list (region-beginning) (region-end)) (list (point-min) (point-max)))) ...


1

The relevant configuration option is search-upper-case. As with many things, you can find this information in Emacs itself. For example, use C-h r to open the Emacs manual, and use i to search the index for isearch. This leads to the Incremental Search topic, which includes a section on Isearch Yank with this: Normally, when the search is case-...


Only top voted, non community-wiki answers of a minimum length are eligible