Skip to content

feat: Toggle movement of all selections versus only the primary selection #13833

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mgazeel
Copy link

@mgazeel mgazeel commented Jun 25, 2025

Hi everyone!

This is my stab at a minimal PR building off of the discussion in #10457.

Here's a short showcase of the proposed improvement:

rec2.mov

Motivation

While performing search-and-replace in some large files I've also found myself wanting to change the primary selection without touching the rest. For me this 'completes' the mental model of multiple selections. With this it should be possible to create arbitrary selections and (in my opinion) there is motivation for adding this in everyday usage.

As a nice aside (although I know this isn't that relevant) other editors fall short here. For example in (n)vim while performing search and replace there is no option to modify just one of the selections. Kakoune also does not offer this option to the best of my knowledge and it is instead a plugin: phantom-selection.

Example

rec1.mov

Edge cases

  1. When moving one selection we get overlap with another they merge, as expected (normalize).
  2. This only controls movement! Editing selections (deletion, etc) still applies to all selections and I think this should be the (default) behaviour.
  3. Having one selection, removing selections, or adding new selections switches back to 'all selection' mode.

Optional additions

The branch also has two commits marked as 'optional', I really wanted to avoid bikeshedding about this so its the: Keymapping of toggling this mode, and the theme parameter for the 'primary' text. It should be easy to cherry pick the comments which are wanted in the merge.

  1. I have this toggle currently mapped at '#', I dont mind how its bound more that the feautre is merged.
  2. The other commit adds ui.statusline.selections.primary-only to describe the styling of the text.

@mgazeel mgazeel changed the title Toggling editing of all selections versus only primary selection feat: Toggling editing of all selections versus only primary selection Jun 25, 2025
@mgazeel mgazeel changed the title feat: Toggling editing of all selections versus only primary selection feat: Togge movement of all selections versus only the primary selection Jun 25, 2025
@mgazeel mgazeel changed the title feat: Togge movement of all selections versus only the primary selection feat: Toggle movement of all selections versus only the primary selection Jun 25, 2025
@Axlefublr
Copy link
Contributor

oh. my. god. this is amazing! completes the multiselection model indeed! considering that we don't have marks

@Axlefublr
Copy link
Contributor

I have just tested this and yep it works! how wonderful :D

@Axlefublr
Copy link
Contributor

could you please add a theme setting like 'ui.cursor.primary' but 'ui.cursor.primary-only'? I figure out what mode I'm currently in exclusively by the color of my cursor; “only the primary selection moves” is kinda like a mode, so that would be great!
or is this too out of scope / difficult to implement?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants