Replies: 3 comments 1 reply
-
Thanks for putting this proposal together! I think it will be a great addition to Helix
I personally don't think there needs to be a visual indicator beyond something in the status line saying how many groups you have and out of those, which one is your primary, similar to how we now have |
Beta Was this translation helpful? Give feedback.
-
While the proposal sounds interesting, this question is why I'm sceptical about it. The only proposed command so far is to group selections by line, which is just the most trivial of use case. I feel like a simple model for managing the groups would feel restricted, incomplete and add more inconsistency to Helix' editing model that what it's worth. Making selection group management very flexible could get very complicated very quickly. Nevertheless, I'll try to throw around some constructive ideas.
I'm not hugely in favor or against, but in my view using macros for these purposes is an appropriate amount of complexity. |
Beta Was this translation helpful? Give feedback.
-
Oh another thought. In the original example, selections were reordered by line:
What if instead, one wanted to reorder by "colum"?
If selection groups existed, I could see myself wanting to transpose them. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Selection groups will let you split your selections into groups. Commands that act on selections will be repeated for each group.
Example use case: Say you have this file and every letter is selected (6 selections, each represented by
[...]
):You want to rotate the contents of each line so the 1st selection on each line is swapped with the 2nd. It will become like this:
Right now, to do this you need macros. So for this case, with the cursor on the first line you would do
QxS <A-)><down>Qqq
But I think there's a more natural way of expressing this action, and that is with selection groups.
A selection group is a sequence of consecutive selections. All selection-based commands like
A-)
(rotate selection contents) always act on a single group.This means we do not need to add any new commands for working with selection groups. Instead, every existing command will be repeated for each selection group. I represent each group
{{...}}
and there is always at least 1 group, just like there is always at least 1 selection. The above initial example will have just 1 group:Say we add a new command that creates a selection group on each line (similar in spirit to
A-s
) bound to the hypothetical placeholder keybindingA-β
:Using that will then create 3 selection groups, one on each line:
Now, using
A-)
will execute the action for every selection group. SoA-β
+A-)
will give you this file:With selection groups, we can replace
QxS <A-)><down>Qqq
with<A-β><A-)>
, which is much easier to think about and makes editing text in Helix much more natural. You would have to reach for macros a lot less.This is a large proposal, and will require lots of discussion. Some things to think about:
thanks @rockboynton for the inspiration
Beta Was this translation helpful? Give feedback.
All reactions