-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add emacs keybindings for mark emulation #22904
Conversation
These keybindings extend the already selected text. This allows closer emacs emulation where subsequent movement commands extend / shrink the current selection instead of dismissing it.
e8e46f1
to
4e6c580
Compare
I've updated this PR to
|
I love this. Particularly the elegance of "mark mode" being activate whenever there is a I've added Currently |
I've tried to test this in various
In a buffer I think these behaviors are fine but I think in the single line editors (search, modals, etC) I think this behavior is a little too jank to ship. How would you feel about changing the keybind contexts to:
Would it be an acceptable compromise to add support for emacs style "mark mode" but only in Full Editor buffers, not in line editors? I also noticed a difference between this an emacs behavior:
Alternatively we could conceivably split the arrow/home/end binds I added to only be used in Thoughts? |
Thank you!
This is great, thanks for adding these.
Alt-/ would be a natural keybinding for this as it is used in Emacs for various text completion mechanisms (by default
You're right, in Emacs selecting text with Shift + arrow keys does not set the mark. But I can't think of a way to replicate this behavior. For users who use Emacs keymap but prefer selecting text with classic Shift + arrow keys this could be a regression and a bit annoying.
I think this is a good compromise. These keybindings are most valuable in file and assistant buffers, and we can omit line editors to keep this PR simple and not introduce counter-intuitive edge cases. I will update the |
This comment was marked as off-topic.
This comment was marked as off-topic.
@ozanmakes This looks good and I'm going to go ahead and merge. We're definitely at an inflection point here. Prior to this change we were just mapping Zed actions to their emacs equivalent keybinds, but selections in emacs behave differently than most GUI editors (VSCode, Zed, etc) and are implemented as an explicit mode. I'm sure some users will not like the changes here, but let's give it a whirl and get some feedback. Thank you! |
Excited to have this in Zed, thank you for merging it and for your great feedback! |
I've been using this for a day and I personally hate it. I'm reverting and am revisiting the creation of a mark mode which requires an explicit In the meantime anyone who wishes to use this mode can paste the following into their user keymap:
|
Understood, too bad it didn't hit the mark for you (no pun intended). An explicit mark mode would indeed be great. Editors often have super intricate VIM emulation but only rudimentary Emacs bindings; if Zed team is open to introducing this, it would make me, and I presume many others, very happy. |
@ozanmakes Can you check this out and let me know if you have any feedback: |
Updates #21927 Replaces #22904 Closes #8580 Adds actions (default keybinds with emacs keymap): - editor::SetMark (`ctrl-space` and `ctrl-@`) - editor::ExchangeMark (`ctrl-x ctrl-x`) Co-Authored-By: Peter <[email protected]> Release Notes: - Add Emacs mark mode (`ctrl-space` / `ctrl-@` to set mark; `ctrl-x ctrl-x` to swap mark/cursor) - Breaking change: `selection` keyboard context has been replaced with `selection_mode` --------- Co-authored-by: Peter <[email protected]>
These keybindings extend the already selected text. This allows closer emacs emulation where subsequent movement commands extend / shrink the current selection instead of dismissing it.
This is a follow up on
Release Notes: