Questions tagged [query-replace-regexp]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
17 views

Automatically save files after multi-file search/replace

How can I get GNU Emacs to automatically save all the files I've changed after doing a multi-file search/replace with query-replace-regexp? Right now I have to switch back to the buffer for every ...
1
vote
2answers
83 views

Using a variable as the REGEXP in `query-replace-regexp`

I know, Emacs allows calling ELisp while replacing a text with a regex, aka C-M-%, which is bound to query-replace-regexp. I'm trying to make use of that to store an unwieldy regexp as a variable, so ...
1
vote
1answer
29 views

How can I catch a block of text to be used in a replacement-part code?

I want to save a block of text in a variable and then do a replacement using that variable in the replacement part. For instance, suppose to do the following replacement: block_of_text ---> \...
1
vote
1answer
72 views

How to find a newline with a regular expression in query-replace-regexp?

I am trying to use find-name-dired and query-replace-regexp to find and replace some blocks of text across multiple HTML files. (Just what is explained here in the Emacs Manual.) query-replace-regexp ...
3
votes
1answer
43 views

Equivalent of query-replace-regexp for multiple regexps

How can I do the equivalent of query-replace-regexp for multiple regexps? For instance, if regexp1 is matched, it should be replaced by text1, and if regexp2 is matched, it should be replaced by text2 ...
2
votes
1answer
37 views

Search and replace with many possible replacements?

Suppose I have a code base with many instances of string "console.log(" for example. I want to replace each one with one of the following six lines: logger(FATAL, logger(ERROR, logger(...
1
vote
1answer
38 views

How to duplicate text but increment a numeric part of a name?

Say that I have rect1 one and I'll multiply it 3 times by yanking. let rect1 = Rectangle { width: 10, height: 40, } let rect1 = Rectangle { width: 10, height: 40, } ...
1
vote
0answers
54 views

How to replace a block of text with a “query-like” approach all at once?

I want to search and replace a block of text with a "query-like" approach all at once. For example, if I have \emph{``Foo $\bar$ baz''} to be replaced by \emph{Foo $\bar$ baz} using a &...
1
vote
1answer
46 views

How can I get the search string from incremental regexp search to use with replace regexp

If I want to do a replace-regexp I usually start with a isearch-forward-regexp so I can get immediate visual feedback on the search string. From there I'd like to grab the search string for using in ...
0
votes
1answer
34 views

.+$ fails to match remainder of line

This matches nothing: Query replace regexp (default \.org.+ → ): \.org.+$ → The same without '$' matches incompletely: I'd like to be able to match \.org and all that follows.
0
votes
1answer
63 views

Regexp: how to search-replace any html attribute in current buffer

Disclaimer: I'm still trying to learn elisp so I have not gotten yet to the RegExp section of the Elisp intro or Emacs manual. I would like to know how to search and replace an HTML buffer that has ...
1
vote
1answer
124 views

How to replace strings including `.` (dot) as first character using dired-do-find-regexp-and-replace

(defun my-find-orgfiles () (interactive) (find-name-dired "." "*py")) (global-set-key (kbd "M-n") 'my-find-orgfiles) Than, t to toggle marked/unmarked files (thus marking them all, since none ...
0
votes
2answers
78 views

query-replace{-regexp} fails in linux in a non-X terminal when I am in anything other than text mode

I am running emacs 26.1 under linux. It has been working fine for over a year. Recently, I upgraded a lot of packages on my machine, but I did not upgrade nor alter emacs in any way. Now, query-...