Skip to content
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 command to merge non-consecutive ranges #7053

Merged
merged 4 commits into from May 19, 2023

Conversation

hamrik
Copy link
Contributor

@hamrik hamrik commented May 15, 2023

Situations may arise in which you want to extend your selection up to a search result, or simply select everything between two or more cursors.

before before

Currently there is no mechanism for this other than badly abusing goto_last_modification as a poor man's mark.1
merge_selections combines all current ranges into a single range spanning from the first selection in the buffer to the last.

Now you can search in visual mode for the token you want to select up to, then hit Alt-minus (since Alt-_ could already merge consecutive selections).

helix_merge_ranges_macro_demo.webm

Footnotes

  1. How to select "until next occurrence"? - Reddit

hamrik and others added 2 commits May 19, 2023 08:02
Heeded the advice of @the-mikedavis to stop iterating over all ranges and simply merge the first and the last range, as the invariants of `Selection` guarantee that the list of ranges is always sorted and never empty.
@kirawi kirawi added A-helix-term Area: Helix term improvements S-waiting-on-review Status: Awaiting review from a maintainer. labels May 19, 2023
Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The A-minus keybinding isn't taken in Kakoune AFAIK so I think this looks good 👍

Copy link
Member

@pascalkuthe pascalkuthe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found myself missing something like this a few times. Thanks for working on this 👍

@pascalkuthe pascalkuthe merged commit 70e4cdb into helix-editor:master May 19, 2023
6 checks passed
@hamrik hamrik deleted the merge_ranges branch May 20, 2023 13:28
aotarola pushed a commit to aotarola/helix that referenced this pull request May 28, 2023
* Add command for merging non-consecutive ranges

* Add `merge_selections` command to book

* Simplify `merge_ranges`

Heeded the advice of @the-mikedavis to stop iterating over all ranges and simply merge the first and the last range, as the invariants of `Selection` guarantee that the list of ranges is always sorted and never empty.

* Clarify doc comment of `merge_ranges`
aotarola pushed a commit to aotarola/helix that referenced this pull request May 28, 2023
* Add command for merging non-consecutive ranges

* Add `merge_selections` command to book

* Simplify `merge_ranges`

Heeded the advice of @the-mikedavis to stop iterating over all ranges and simply merge the first and the last range, as the invariants of `Selection` guarantee that the list of ranges is always sorted and never empty.

* Clarify doc comment of `merge_ranges`
Triton171 pushed a commit to Triton171/helix that referenced this pull request Jun 18, 2023
* Add command for merging non-consecutive ranges

* Add `merge_selections` command to book

* Simplify `merge_ranges`

Heeded the advice of @the-mikedavis to stop iterating over all ranges and simply merge the first and the last range, as the invariants of `Selection` guarantee that the list of ranges is always sorted and never empty.

* Clarify doc comment of `merge_ranges`
wes-adams pushed a commit to wes-adams/helix that referenced this pull request Jul 4, 2023
* Add command for merging non-consecutive ranges

* Add `merge_selections` command to book

* Simplify `merge_ranges`

Heeded the advice of @the-mikedavis to stop iterating over all ranges and simply merge the first and the last range, as the invariants of `Selection` guarantee that the list of ranges is always sorted and never empty.

* Clarify doc comment of `merge_ranges`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants