EFLS_ · 2022-02-28 20:56
Hi
I'm looking to enhance my writing experience by dragging text around.
In Org-mode, dragging the current paragraph (or subtree, or list item) up and down is easy with `M-up` and `M-down`.
I'm an Evil user, so for swapping two regions, there's `evil-exchange`.
Is there a package that would allow me to drag the current region up or down? Or perhaps right or left, along the same line? Or does anyone have any pointers on how to best write something that achieves this?
Cheers
oantolin · 2022-02-28 22:33
I wrote a small [drag-region](https://github.com/oantolin/emacs-config/blob/master/experiments/drag-region.el) package once. You mark a region, turn on `drag-region-mode` and then your normal motion commands will drag the region along until you turn the minor mode off again. I never tested it with evil.
takeonrules · 2022-03-01 01:27
Have you looked at move-text? https://melpa.org/#/move-text
Illiamen · 2022-03-01 01:28
Maybe you want to customize `mouse-drag-and-drop-region`? See here: https://www.gnu.org/software/emacs/manual/html_node/emacs/Drag-and-Drop.html
organic-bookworm · 2022-03-01 08:41
Doom Emacs sets up [drag-stuff.el](https://github.com/rejeep/drag-stuff.el) for this.
> drag stuff (words, region, lines) around
I don't use it personally, but a quick triage has shown it doesn't work with Evil's block selections (expected) and rectangular regions.
EFLS_ · 2022-03-01 19:49
Thanks! Tried it quickly, but doesn't seem to work well with Evil (or I'm doing something else wrong – the region is deleted when I exit the minor mode). I'll try to wrap my head around the Elisp and maybe try to come up with something myself!
EFLS_ · 2022-03-01 19:50
I haven't, but I'll give it a look, thanks.
EFLS_ · 2022-03-01 19:52
Thanks, didn't know this exists. At first glance it's only for the mouse and I don't see anything related to keyboard manipulation.
EFLS_ · 2022-03-01 19:53
But since it's Doom, it should work with other types of regions & Evil, right? I'll check it out!