How to do this Vim Trick in Emacs? reddit / emacs ---------------------------------------------------------------------- timmymayes · 2022-06-20 00:38 Saw this neat vim trick and was curious how I could pull this off in emacs. [https://youtu.be/futay9NjOac?t=431](https://youtu.be/futay9NjOac?t=43 1) ---------------------------------------------------------------------- mattias_jcb · 2022-06-20 00:58 That's neat! I tend to make a keyboard macro or maybe `M-s o` with some post processing. Definitely not as quickly as he did it though. ---------------------------------------------------------------------- 7890yuiop · 2022-06-20 02:18 I would use `mark-defun` and `occur` to obtain the initial text matching the regexp, copy the text from the occur buffer, yank it, and then maybe `exchange-point-and-mark` to reactivate the mark/region, and search/replace (in region). It's not as streamlined as that video, but it's still pretty simple. ---------------------------------------------------------------------- cretan_bull · 2022-06-20 03:15 You can do something similar with [multiple cursors](https://github.com/magnars/multiple-cursors.el). ---------------------------------------------------------------------- _viz_ · 2022-06-20 05:57 I think giving a prefix arg to occur and using a more exact regexp should alleviate some of the pain later on. ---------------------------------------------------------------------- trimorphic · 2022-06-30 22:31 Using evil in emacs you'd just do exactly what he did in vim, using the same exact commands. ---------------------------------------------------------------------- timmymayes · 2022-06-30 22:32 Looking for non vi mode. I prefer mod keys to modal editing personally. Thanks for the tip though!