Reputation: 277
I often have complex search patterns in vim. If I find the exact pattern, that matches, what I'm searching and want to delete all the matches, I have to go into command mode type :%s/...//
with ...
being the complicated pattern.
Is there an easier way to delete all results of a search, without going through them one by one?
Upvotes: 2
Views: 259
Reputation: 37
If you absolutely need to avoid %s you can use gn together with a macro. Something along the lines of:
qq
- record macro to register q
dgn
- remove selection
n
- jump to next match
q
- stop recording
9999@q
- run macro 9999 times
I would not call this a good solution by any means (the by @L3viathan proposed %s without entering a search pattern is superior), but it resolves the question as stated.
Upvotes: 2
Reputation: 27333
This isn't completely completely without :%s/..
, but without typing the pattern again:
:%s///g
If you leave the pattern empty, it will repeat the search. If that's something you do often, you can bind a key (sequence) to it.
Upvotes: 5