How to repeat a command with substitution in Vim?

Whaledawg picture Whaledawg · Dec 19, 2008 · Viewed 9.7k times · Source

In Unix the ^ allows you to repeat a command with some text substituted for new text. For example:

csh% grep "stuff" file1 >> Results
grep "stuff" file1
csh% ^file1^file2^
grep "stuff" file2
csh%

Is there a Vim equivalent? There are a lot of times I find myself editing minor things on the command line over and over again.

Answer

LearnOPhile picture LearnOPhile · Jul 18, 2013

Specifically for subsitutions: use & to repeat your last substitution on the current line from normal mode.

To repeat for all lines, type :%&