Reputation: 18564
I am using slash for searching for stuff within vim. I'd like to use the regex that I used for search in a command (a substitute command to be exact). Is there a simple way to do it?
Upvotes: 6
Views: 284
Reputation: 4214
Use the useful CTRL-R:
In the command line, if you are making a substitute command search with :, you can press CTRL-R and then / to insert the last search into the command line.
It's great that the opposite works too: If you are making a search with the slash, you can add your last command with CTRl-R and then :
Upvotes: 6
Reputation: 11788
the subtitute command will use the last search if you do not specify it, so just use:
:s//<replacement>
Upvotes: 12