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

[Proposal] Extend till next selection #11524

Closed
jabcross opened this issue Aug 19, 2024 · 6 comments
Closed

[Proposal] Extend till next selection #11524

jabcross opened this issue Aug 19, 2024 · 6 comments
Labels
C-enhancement Category: Improvements R-duplicate Duplicated issue: please refer to the linked issue

Comments

@jabcross
Copy link

What it says on the tin. A motion to be used with multiple cursors that will extend the selection until the next cursor.

So that this (brackets are selections)

[A1]
A2
A3
[B1]
B2
[C1]
C2
C3

becomes this:

A1
[A2
A3
]B1
[B2
]C1
[C2
C3
... EOF ]

Would be handy for a couple of use cases that currently require macros.

@jabcross jabcross added the C-enhancement Category: Improvements label Aug 19, 2024
@chtenb
Copy link
Contributor

chtenb commented Aug 19, 2024

Sounds like "select till" rather than extend. Could you also mention the use cases you talked about?

@jabcross
Copy link
Author

jabcross commented Aug 19, 2024

Example: converting

if char == 'a':
   # some arbitrary number of lines
   return 'value'
elif char == 'b':
   # some other arbitrary
   # number of lines
   return 'value'
elif char == 'c':
   # some third
   # arbitrary
   # number of lines
   return 'value'
# ...

to

if char == 'a':
   # some arbitrary number of lines
   return 'value_a'
elif char == 'b':
   # some other arbitrary
   # number of lines
   return 'value_b'
elif char == 'c':
   # some third
   # arbitrary
   # number of lines
   return 'value_c'
# ...

Process:

  • %s==<enter> (put a cursor in each ==)
  • llly (copy the appropriate character to the per-cursor clipboard)
  • select_till_next_selection (proposed action, will create selections that enclose the body of each if)
  • sreturn<enter> (select each return)
  • 2t'a_<esc> (insert _ at end of string)
  • p (paste the character from the per-cursor clipboard)

I cannot find another way to do this with multiple cursors. A macro that does this process with a single cursor will not work properly with multiple cursors.

If there was a variant of f that took a string, or if / worked independently with multiple cursors, this could also be achieved, but I think this method is more general.

An extend version and a backwards version would also be handy.

@kirawi
Copy link
Member

kirawi commented Aug 19, 2024

Something like this would depend on resolving the latter part of #2298 (comment). This also sounds like it is a duplicate of #5672

@kirawi kirawi closed this as not planned Won't fix, can't repro, duplicate, stale Aug 19, 2024
@kirawi kirawi added the R-duplicate Duplicated issue: please refer to the linked issue label Aug 19, 2024
@jabcross
Copy link
Author

Well, my proposal doesn't really create adjacent selections, so I don't understand what you mean by the linked comment. The original selections will not end up selected and will therefore be between any of the resulting selections.

Also, this was just one example of usage. I can think of other uses than the multicursor search problem. Not sure how it's a duplicate.

@chtenb
Copy link
Contributor

chtenb commented Aug 20, 2024

Also, this was just one example of usage. I can think of other uses than the multicursor search problem.

Can you elaborate and actually give the example that could not be solved by multicursor search?

@jabcross
Copy link
Author

jabcross commented Aug 20, 2024

Any situation where you have a list of header-body type structures and you want to alter the bodies with information from the heads. Or when you want to change between editing delimiters to editing values in a list. But I think my provided example is enough.

I'm sure many things could be solved with multicursor search, but I don't think that being the "only" solution to a given situation should be the sole cutoff criterion to whether a proposal is considered or not. After all, anything could be solved with just regex substitutions and hjkl or with macros. It's just handy to have options.

I just wanted to know if this is something people would find useful, to maybe work on a PR. And if not, what are your perceived downsides, to inform future suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Improvements R-duplicate Duplicated issue: please refer to the linked issue
Projects
None yet
Development

No branches or pull requests

3 participants