5

In many editors it is standard to move selected text by dragging and dropping it with the mouse.

In emacs dragging selection with the mouse starts a new selection by default.

This is extremely annoying, as normally (everywhere else) such a behavior is achieved by clicking mouse to deselect text first. Besides, I cannot imagine a single use case for this emacs behavior - starting a new selection immediately after the first one without doing anything with the first selection.

How can I configure emacs to drag existing selection like in all other editors?

5
  • 3
    Hmmm . . . I was a professional word processor / typist from about 1986 to 2002, and I've worked for myself doing my own document preparation from 2002 to the present. I can honestly say that this is the first time I've ever even thought about the possibility of dragging text with the mouse. :) I'll definitely have to give that a try. :)
    – lawlist
    Mar 24, 2016 at 23:29
  • Sure, emacs is all about keyboard, but why then enable mouse there and not have it implemented in a way it is expected to be? Mar 24, 2016 at 23:42
  • @AlexanderShcheblikin Maybe give the implementers the benefit of doubt? What you expect seems to be different from what they expect, but maybe there is a reason? (I've never dragged and dropped text in any program, Emacs or other, for what it is worth, so I have no idea what to expect).
    – asjo
    Mar 25, 2016 at 0:10
  • Check out the inbuilt mouse-copy package. I'll write a proper answer when I get to a computer. You can search for mouse-copy in my config. Mar 25, 2016 at 1:08
  • FYI to easily drag stuff with the keyboard: github.com/rejeep/drag-stuff.el
    – Ehvince
    Mar 19, 2019 at 15:18

1 Answer 1

12

tldr;

  • Add (setq mouse-drag-and-drop-region t) in you init file.
  • Restart or C-c d R to reload if you're using Doom-Emacs.

enter image description here

I just find out (SURPRISINGLY) that Emacs as text drag and drop. And this since version 22.1 released in 2007. This is actually a feature I didn't even dare to google to see if it's available. Even Sublime Text can't (currently in Linux)

7
  • support for DnD It appears to be limited to the current frame. I can drag text from one area of my buffer and drop it in another area, and I can split my frame and open a second buffer and drag text between the two, but I can't drag text from one frame and drop it into another frame (or into another application). Ubuntu 18.10 with GNOME 3 and emacs --daemon, in case any of that matters.
    – Dan O
    Mar 19, 2019 at 13:48
  • Yes, I just find that limitation. At least you can drop text from other application, not the other way around.
    – Asme Just
    Mar 19, 2019 at 14:15
  • Can you scroll with the mouse wheel while dragging? May 31, 2019 at 11:17
  • @AlexanderShcheblikin I haven't tested it yet.
    – Asme Just
    May 31, 2019 at 11:27
  • Added this variable and it has no effect for me (after restart). Just changes the selection and sets the mark, as before. May 31, 2019 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.