Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That first trick in the video - select some text, do multi-site replacement - how do I do this in Emacs (35 year user, but have no idea :)


There is multiple cursors[1]. Checkout the video by emacsrocks[2]. You can combine that with regex tools if you need to do this over complex patterns[3]. There is also iedit which may fit your mental model better[4].

[1] https://github.com/magnars/multiple-cursors.el

[2] http://emacsrocks.com/e13.html

[3] https://github.com/benma/visual-regexp-steroids.el

[4] https://github.com/victorhge/iedit


https://streamable.com/t4i5tx

The highlights and fancy replacement preview are added by a plugin called anzu[0], but otherwise this is a standard emacs feature. I couldn't tell you what the default binding is but the function is query-replace-regexp.

(I don't understand why people are trying to bring multiple cursors into this)

[0] https://github.com/emacsorphanage/anzu


I use replace-replace-regexp a lot. What was shown in the video was qualitatively different. Multiple sites were shown changing at the same time. That's not what q-r-r does, even with "bang" version mentioned above. You could actually see the old text replaceable by the being-entered new text.


The buffer was not being edited when the replacement was shown to be happening. The plugin anzu uses overlays[1] to show the text being replaced and the replacements.

[1]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Ov...


If you select a region with transient mode on, then `query-replace` (`M-%` by default) will only affect the region. So select the region you want the change to effect (just like in the demo video), hit `M-%`, then type the old and new text, then you can type `!` when prompted for what to do and all instances of old become new only within the region.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: