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

Feature request: replacement #21

Open
elkarouh opened this issue Feb 26, 2023 · 6 comments
Open

Feature request: replacement #21

elkarouh opened this issue Feb 26, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@elkarouh
Copy link

elkarouh commented Feb 26, 2023

Hi,
I recently switched from emacs to vi and I miss some functionality from this emacs package
https://github.com/wolray/symbol-overlay
When the cursor is on a highlighted word, pressing the r key will prompt you for a replacement.
This is very handy when programming.
Another question: in the emacs plugin, when the cursor is on a highlighted word, a specific mode is entered and pressing n or p will bring you to the next or previous highlighted word. Is it possible in vi to have the same functionality?
Thanks for the great work 👍

@azabiong
Copy link
Owner

Thanks for your interest in this plugin.
As for replacement, I mainly use the language server plugin function which supports scope based replacement. Sometimes, I use the following mapping in normal mode to replace the word under the cursor:

nn <leader>r  "ryiw:%s/\V<C-R>r\C//gc<Left><Left><Left>

To navigate through the selected text, you can use the * key to select a pattern, then use the n and N keys.

@elkarouh
Copy link
Author

Thank you for responding.
What you propose are work-arounds.
My question essentially boils down to : is it possible to enter a minor mode in which the major mode key bindings are overridden.
In normal circumstances, i want r to perform single letter replacement, but when the cursor is on a highlighted word, i want to be prompted for replacement of all occurrences of the word.

@jqhr
Copy link

jqhr commented Apr 13, 2023

I need this feature too.
Because some text with "-" or other non keyword can not distinguish by , so I offten use visual mode to highlight those text.
Until now, I have not find any better way to replace those text.

@azabiong
Copy link
Owner

Alright, then I will try highlighting when replacing, and let's see if it's convenient. Thanks.

@azabiong azabiong added the enhancement New feature or request label Apr 14, 2023
@jqhr
Copy link

jqhr commented Apr 14, 2023

Thx

@azabiong
Copy link
Owner

The plugin can now select the correct highlight at the cursor position when multiple highlights overlap. We can easily check this using the latest version of the HiErase function. So, it looks like the plugin is now ready to accept input for this new feature! 😄
Separately, I discovered a very powerful plugin for the replacement function:
https://github.com/nvim-pack/nvim-spectre
And also, I found a very interesting video about refactoring:
https://www.youtube.com/watch?v=oQB8lYUZtrY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants