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
1
vote
1answer
72 views

Regexp doesn't work

I want to convert all the deques in my python code to lists. I.e. deque([1]) should become [1]. I tried M-% deque(\(.+\)) RET \1 RET, but it said Replaced 0 occurences. What's wrong with my regexp?
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
303 views

How to combine the history of isearch and query-replace?

I often use isearch (C-s normally or / in evil) and then want to use that query (or part of it) for replacing. This answer explains how to cycle history, but M-p cycles the history for each mode ...
3
votes
2answers
122 views

How to query-replace across all hits in a compilation-mode buffer

How can I run a query-replace on the all the files pointed to by an arbitrary compilation-mode buffer? I think to be usable this would need to be resumable from point in the compilation-mode buffer. ...
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 ...