3

M-: (query-replace-regexp foo "bar") RET


3

query-replace-regexp can do the trick. Select the region you want for replacing and : C-M % \brect1\b RET rect\,(1+ \#) RET ! for more information (info "(emacs)Regexp Replacement") ;;;;;;;;;;;;;;;;;;;;;;;;; A function for more comfort;;;;;;;;;;;;;;;;;;;;;;;;; (defun multiple-paste-renum(n renum paste ) "Paste N copy of PASTE and ...


2

You could trigger save-buffer after the replace. I believe the following should work: (add-hook 'replace-update-post-hook 'save-buffer)


2

Is this for interactive use? I suppose so. As the doc string for replace-regexp says: This function is for interactive use only; in Lisp code use `re-search-forward' and `replace-match' instead. Are you really asking about replace-regexp, and not query-replace-regexp? Because if you use the latter then the answer is included in Isearch by default: ...


2

Try this. Enter an empty regexp interactively to stop adding regexp/replacement pairs, and start replacements. (defun query-multi-replace-regexp (&rest pairs) "Query replace for each regexp and replacement string in PAIRS." (interactive (let (pairs regexp replacement) (while (and (setq regexp (read-regexp "Query replace regexp&...


1

In reading the doc of query-replace-regexp, it mentions the \, syntax in the replacement text part, but not in the regex part: In interactive calls, the replacement text can contain ‘,’ followed by a Lisp expression. So AFAICT, you cannot do what you want interactively: you'd have to write your own souped-up version of query-replace-regexp as @choroba ...


1

First, note that query-replace-regexp matches either from the point to the end of the buffer or in the active region. So if your point is after what you are trying to match it will not work. With that out of the way, the following works for me: M-x query-replace-regexp RET <div class="copyright"> C-q C-j RET test RET And you should get a ...


1

How about this? (defun my-query-replace-console-log () "Replace instances of console.log( from a menu of options." (interactive) (let ((prompt "1:fatal, 2:error, 3:warning, 4:info, 5:log, 6:debug ? ") (replacements '((?1 . "logger(FATAL,") (?2 . "logger(ERROR,") ...


1

Using web-mode you can traverse the dom tree element by element and then traversing element attributes killing/sparing each one manually without having to code anything, just learning the keybindings. Doing it automatically will require some coding. I guess you can do something similar with other related modes with more or less effort. If you're looking for ...


1

This really has nothing to do with find-name-dired. This is about Q in Dired buffers (including from find-name-dired). Q is dired-do-find-regexp-and-replace. That command treats your first input pattern as a regexp. And . in a regexp matches any character except newline. What you want to use, instead of .value, is [.]value. That is, you want a pattern ...


1

I ended up fixing the issue by building and starting to use emacs-28.0.50: https://github.com/emacs-mirror/emacs I had to update some ancient, deprecated constructs in some of my old startup files so that this version of emacs would run. But in any case, this problem with query-replace{-regexp} doesn't exist in 28.0.50. I still don't understand how making ...


1

FWIW (this isn't an answer; just more context) In 26.3, the only call to buffer-substring-no-properties in perform-replace is: (setq search-string-replaced (buffer-substring-no-properties (match-beginning 0) (match-end 0)) ...) So to get buffer-substring-no-properties(0 1) in the backtrace, ...


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