vim-highlighter icon indicating copy to clipboard operation
vim-highlighter copied to clipboard

Feature request: replacement

Open elkarouh opened this issue 2 years ago • 6 comments

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 👍

elkarouh avatar Feb 26 '23 07:02 elkarouh

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.

azabiong avatar Feb 26 '23 11:02 azabiong

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.

elkarouh avatar Feb 26 '23 18:02 elkarouh

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.

jqhr avatar Apr 13 '23 17:04 jqhr

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

azabiong avatar Apr 14 '23 03:04 azabiong

Thx

jqhr avatar Apr 14 '23 04:04 jqhr

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

azabiong avatar Apr 26 '24 03:04 azabiong