-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Search from each selection #5672
Comments
Ran into a case were running a macro with multiple cursors will cause the macro to behave differently for primary vs the others. Would definitely appreciate this! |
I want to comment here a work-around, for anyone (e.g., future me) searching for how to accomplish this (until such time as something better is implemented):
and then trim the selection as necessary. |
@xxxserxxx what are I found a decent workaround, which is maybe the same as you're suggesting? [keys.select]
n = ["extend_search_next", "merge_selections"]
N = ["extend_search_prev", "merge_selections"] It can have unexpected behavior if you're starting with multiple cursors though. |
@rcorre Your solution is frustratingly almost what I want; but I (and what people are requesting in this issues, I think) don't just want to keep searching for the same things. I want to start at some point and then interactively search forward for some pattern, extending the current selection. Think:
I want to jump to Now that |
you could |
For that use-case we could respect the mode in |
|
Yeah, I don't remember what I meant to write; I had A-/ bound to something, or I just typed it in from a faulty memory. The entire work-around was so klugy I rarely used it. @sibouras' solution does the same thing and is cleaner. Cognitively, being in visual mode and having selected some text, and having searching forward (or backward) causing the selection to be lost -- I'm trying to understand why that is the current behavior. Is that the intuitive behavior for someone, or is it some technical difficulty? |
I believe it's just an oversight. Currently select mode has no effect in |
it would make more sense for |
That isn't about respecting mode. |
ah i see, it would be nice though when in select mode
|
If we're thinking that I want to try and get a PR up to fix this issue, but just want to confirm the desired behaviour before I get started. |
@the-mikedavis is already testing an Implementation of this that we discussed that matches what we want so starting from scratch with a new PR probably doesn't make sense |
Ah, thanks for letting me know! I wasn't aware this was being worked on. As an aside, I also noticed a slight bit of inconsistency in that using Screen.Recording.2024-06-02.at.14.16.48.mov |
That's intentional: #8875 (comment) |
The current search (
/
,n
andN
) only searches from the primary cursor. In select mode (v/
) this can be used to add matches of the search pattern as new cursors.It would also be useful to be able to search from every cursor. Instead of adding new selections for the next match from the primary cursor, this search would replace or extend the current selection(s) (depending on normal or select mode).
This behavior would be the same as textobjects like
]p
or]f
. This could be used together with #1383 to implement regex-based textobjects like searching for numbers, dates, version control markers (#4647), etc.. And I think it could be useful on its own in some multi-cursor scenarios and some single-cursor scenarios like #5668.There might be some overlap with this and #4635 with how search matches would be computed.The text was updated successfully, but these errors were encountered: