Closed huyz closed 10 years ago
As a bonus this method even works in the IdeaVim plugin for Intellij IDEA (well, sorta -- as soon as they fix the highlight and scrolling issue)
In general I agree and this is what I do. I have to admit, there is something to be gained from having the changes you make happen on each key press, rather than on execution of some carefully constructed regexp, however.
If you've ever used emacs in evil-mode, you get the best of both worlds. As you're entering the :%s/pattern/replace/
command, it alters the buffer to show exactly what it's matching and what it is going to be replaced with. If love something like that for Vim.
But the alternative method that I'm talking about does give visual feedback of what's to match. If you have 'hlsearch'
turned on, the selection *
will immediately show you all the instances that match. And hitting y
for each confirmation does change only one match per key press.
I guess what we don't see is how everything changes as we type the replacement text. I could see where that could be useful if we're worried about character alignments for example.
Edit: @d11wtq re-reading what you wrote, I see that's what you meant.
@d11wtq I think vim-over is exactly what you're talking about. Love that plugin!
Is this still an issue?
It's not an issue. I think I was trying to figure out if I was missing something.
I tried this for a while, but I wonder why we would not just use the confirmation flag
/c
of a search and replace.The benefits of this approach (besides the fact that it's available in all vim installations) are that you can select more than just a word and you can narrow down the search within a region.
For example, select the text you want to replace by placing your cursor and hitting
*
org*
orviW
or whatever. Then select the region by hittingshift-V
and select some lines. Then do:s/^R//replacement/gc
where^R/
inserts the last thing that was searched. Then you get a visual way to confirm which items to replace.Are there are any use cases that vim-multiple-cursors offer that I can't think of?