vim, I typed
/foo Enter and found some matches.
Now I want to replace all instances of
Can this be done without retyping the
foo? (e.g. into the command line following
Yes, you can do it with
Explanation: in the substitute command when the search pattern is empty, Vim uses the last search pattern.
Alternatively, you can explicitly paste the last search pattern, which is stored in a special register. You can quickly insert its contents by typing Ctrl-R+/ in insert or command mode.
So enter command mode, type