reddit / emacs

Multi-region in emacs

kikechan · 2022-05-30 10:20
Is the ability to have multiple regions selected simultaneously possible in emacs? There is one possible "use-case" covered for highlighting right now (`highlight-regex`), but it uses regex. Being able to interactively select multiple regions and then execute something on them would be a total game changer. This has been a feature in Microsoft Word for decades.
HARITHKAUSHIK16 · 2022-05-30 10:29
I know it's possible through the multiple cursors package, but you need to use more than one cursor to get that effect. I wonder if it's possible in vanilla emacs. Maybe someone more knowledgeable than I am will chime in.
kikechan · 2022-05-30 10:32
Multiple cursors is only for editing text through typing though, right? Does it play well with wrapped lines?
HARITHKAUSHIK16 · 2022-05-30 10:37
Not sure about the wrapped lines but I'm like 80% sure you can set marks and expand region (don't quote me on that ; I've only played around with it a little lol.) There's also something called secondary selection with the meta key and mouse click. That might partially fulfill your brief.
myme · 2022-05-30 12:29
`multiple-cursors` totally allows to have multiple regions, and perform most kinds of editing commands, e.g. edit text, select regions, run `exchange-point-and-mark`, apply `upcase-word`, kill text. It's even possible to kill multiple regions, then move the still active multiple cursors together to another location and yank which will insert the killed contents in order. It doesn't do anything special with wrapped lines – every command is applied at each cursor position in the same way as if there was only one active cursor position, that worked well for me so far.