How to recall search pattern when writing replace regex pattern in Vim?
Posted
by Tom Morris
on Stack Overflow
See other posts from Stack Overflow
or by Tom Morris
Published on 2010-05-29T14:47:37Z
Indexed on
2010/05/29
14:52 UTC
Read the original article
Hit count: 565
Here's the scenario: I've got a big file filled with all sorts of eclectic rubbish that I want to regex. I fiddle around and come up with a perfect search pattern by using the / command and seeing what it highlights.
Now I want to use that pattern to replace with. So, I start typing :%s/ and I cannot recall what the pattern was. Is there some magical keyboard command that will pull in my last search pattern here? If I'm writing a particularly complex regex, I have even opened up a new MacVim window, typed the regex from the first window into a buffer there, then typed it back into the Vim window when writing the replace pattern. There has got to be a better way of doing so.
© Stack Overflow or respective owner