Questions tagged [query-replace]

query-replace is a built-in Emacs command for interactively replacing one string with another in a buffer. query-replace-regexp does the same thing, but with support for matching regular expressions. Use this tag for both commands.

Filter by
Sorted by
Tagged with
3
votes
2answers
84 views

Make region(s) invisible (not evaluated) to query-replacy and similar commands

Is there a way to make some regions of the buffer invisible (I mean not evaluated by) to query-replace and similar commands? Let me better explain with an example. Let's take a piece of LaTeX code .....
5
votes
1answer
294 views

Reusing previous inputs (old or new) for query-replace

Most functions in emacs keep a default option, with the last arguments used. Is it possible to reuse some of the default arguments while changing others? For example, when using search and replace, a ...
3
votes
1answer
284 views

Find and remove consecutive duplicated words while ignoring case

I am trying to find and remove duplicated words in a LaTeX file. Right now I am using query-replace-regexp with the regular expression \b\(\w+\)[ #]+\1 where # stands for line-break (C-q C-j). This ...
1
vote
2answers
1k views

Named groups for query-replace-regexp

I'd like to define a function to do a query-replace-regexp with a pattern I often use. When not using capture groups, it works: (defun my-replace () (interactive) (query-replace-regexp "[[:...
15
votes
1answer
4k views

How to perform case-sensitive query-replace?

When I do M-x query-replace to replace all occurrences of v by w, then it also matches V (uppercase V). How to force emacs to only find lowercase v ?
3
votes
1answer
56 views

(RegEx-)Replace: Sporadic Match data clobbered by buffer modification hooks

I know this was asked in other contexts already, but I couldn't find anything related to C++ development with my hooks that could help me. I am working a lot with replace and query-replace and query-...
2
votes
2answers
152 views

Query-replace-regexp alternative capable of handling nested braces?

TL;DR Is there some method in Emacs to replace text with nested braces/parentheses? Example I had a situation where I had to replace \dchi{ARG1}{ARG2} by \chi^{ARG2}(ARG1) For simple cases, ...