Sublime Forum

FR: Copy Text by Dragging

#1

I would love to have the feature to copy text by dragging selected text with a modifier key pressed.

“Other editors” I’ve used allow this by (on the Mac) dragging selected text while holding the “Option” key, whereby a copy of the selected text is inserted at the cursor location upon releasing the mouse button (or otherwise ending the drag action by whatever pointing device is in use).

This feature would save me a LOT of unnecessary keystrokes by replacing CMD+C > Move > Click > CMD+V with a simple OPT+Drag.

0 Likes

#2

this is possible on Windows with Ctrl+drag, presumably its in the default mouse bindings on Mac as well. Maybe use https://packagecontrol.io/packages/PackageResourceViewer to look at the OSX mousemap in the Default package.

0 Likes

#3

Nothing there indicating this ability.

0 Likes

#4

The TL;DR version of this post is that it looks like Sublime is doing something special on Windows that it’s not doing on MacOS, or at least it seems like there is nothing overtly special about how things are set up that would control it. This may be related to how dragging text doesn’t work at all on Linux (i.e. it’s implemented per-platform and thus may behave differently). Or alternatively I may not know what I’m talking about.

In any case, the windows sublime-mousemap contains this entry for the first mouse button being used with the Ctrl key:

    {
        "button": "button1", "count": 1, "modifiers": ["ctrl"],
        "press_command": "drag_select",
        "press_args": {"additive": true}
    },

As seen here, if you have selected text and you perform a drag with Ctrl held down, this command is logged to the console as soon as the drag starts, and when you let go of the button the selected text is dropped but also left at the original location:

Similarly the OSX sublime-mousemap has this entry for the Command key on the same button:

    {
        "button": "button1", "count": 1, "modifiers": ["super"],
        "press_command": "drag_select",
        "press_args": {"additive": true}
    },

However performing the same steps as above on MacOS doesn’t have the same result:

Here the command is logged right away as on Windows, but when you release the button nothing happens.

The fact that it looks like it’s trying to perform a drag but nothing is happening on release makes this seem like less of a feature request and more of a bug report instead. As such it may be worth reporting on the issue tracker to ensure that the devs have eyes on it.

2 Likes

#5

It appears to me this block of code (on Mac at least) is just there to allow for an additive selection, which does work correctly. (Interestingly, the subtractive selection immediately following this block does not appear to work.)

0 Likes