chrisgrieser / nvim-rip-substitute

Perform search and replace operations in the current buffer using a modern user interface and contemporary regex syntax.
MIT License
116 stars 5 forks source link

Feature Request: Replace current match #6

Open stefanwatt opened 3 weeks ago

stefanwatt commented 3 weeks ago

Checklist

Feature Requested

First off let me say I'm willing and able to implement this feature if you want me to. If I understand correctly, this plugin always replaces all matches on confirm. Which would be equivalent to :s/foo/bar/g. If that assumption is not correct, then this can be closed, I guess.

I would like to be able to do the equivalent of :s/foo/bar/gc. So only ever replace the current match when confirming the replacement. Not sure if this is something you're interested in integrating.

To cohesively integrate that into the existing plugin would require some synchronization/decisions on several topics like:

These keymap changes obviously aren't the only way to do this, but if we do it, then we should think about it.

Those are my thoughts so far. Let me know if you would accept a contribution for this.

Relevant Screenshot

No response

chrisgrieser commented 3 weeks ago

That is correct, that behavior is not implemented yet.

The keymap changes you suggest make sense, though I think not a big deal.

The tricker part is that such a feature would require modifications of a lot of existing features, such as the incremental preview and the range backdrop due to movements of the viewport to track the current match.

Not a hard task, but a lot of changes that would have to be made for this to work correctly. If you are up for it, I am open to a PR.

stefanwatt commented 3 weeks ago

Ok. Great. I was actually working on a similar plugin, so maybe I can reuse some code. Let's see if I can get a prototype working tonight.