zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
35.33k stars 1.79k forks source link

Middle Click + Drag Multicursor #11990

Closed donatj closed 2 weeks ago

donatj commented 2 weeks ago

Check for existing issues

Describe the feature

I would really like it if middle click + drag was added for creating multiple cursors and multiline selections similar to how Sublime, VSCode and Intellij editors do so.

I was frankly kind of surprised I couldn't find a feature request for it.

If applicable, add mockups / screenshots to help present your vision of the feature

Here's a little video of it working in Sublime Text

https://github.com/zed-industries/zed/assets/133747/eb53034c-02e3-4034-984b-742be9d71708

mikayla-maki commented 2 weeks ago

Interesting, so it acts like a drag but each new line becomes it's own multi cursor...

Well, not quite a drag, as it doesn't extend a specific line's selection if the cursor moves vertically, only when it moves horizontally, but something like that.

donatj commented 2 weeks ago

Yep. It's kind of similar to selecting a box of text by holding down alt and dragging in Terminal.app except each selected line gets its own cursor on whatever side the drag ended

Terminal Dragging right to left Dragging left to right
image image image
mikayla-maki commented 2 weeks ago

Ahh! This feature already exists, under alt-shift-left-mouse-drag. I'll see about adding a middle click binding for it :)

donatj commented 2 weeks ago

Dang that was FAST! Thank you so much!

cisoun commented 1 week ago

Hi! First, thanks for the feature!

I've just noticed the selection has to be made in weird way though. To make it work, this is what I have to do: 1) Middle click and release 2) Left click and drag

My expectation was: middle click -> drag

Is this intended?

Zed preview 0.137.0, MacOS

major-hmhco commented 1 week ago

I am also observing a similar issue - simply middle-clicking and dragging does not activate multicursor select; I have to hold middle-click then left-click/drag then release middle-click to get a multicursor selection. It's almost as though middle-click has been bound to the Opt+Shift part of the "standard" keybind

I also experience strange behaviour in a multi-pane editor environment - when selecting a block in pane A, pane B also appears to see selection/highlighting. When I change focus to the second pane (using keyboard shortcuts) I find that the second pane's selection is carried over from the first pane, rather than staying where it was before interaction. This behaviour does not seem to present with the "standard" Opt+Shift+LClickDrag binds. It seems as though all middle-click operations affect both panes and not just the one being interacted with.

Zed preview 0.137.0, MacOS 12.7.4, 2021 MBP w/ M1 Pro

CurbaiCode commented 1 day ago

I am also experiencing a strange behavior. If I open a new file and alt-shift-left-mouse-drag, it acts as if the starting position for the command is the beginning of the file (the default new cursor location) and not at the location the mouse was at when the command was called.

Zed: v0.137.5 (Zed)
OS: macOS 12.6.6
Memory: 16 GiB
Architecture: x86_64