David542
David542

Reputation: 110267

How to repeat find/replace command in vim

If I do a substitution, for example:

:s/ov/xx/g

To substitute "ov" with "xx". However, if I press the . command on another line, it seems like it isn't repeating that find-and-replace operation. Instead it seems to insert a space when I try it again on the next line.

Why not? Is there a way to re-do that command?

Upvotes: 2

Views: 2773

Answers (2)

D. Ben Knoble
D. Ben Knoble

Reputation: 4673

The builtins are & and :&&

Upvotes: 1

Z4-tier
Z4-tier

Reputation: 7978

You can repeat the last command made in command-line-mode (those made at the : prompt) with @: and then use @@ to repeat the same change thereafter. Using . will repeat the last change that was made in normal-mode.

Upvotes: 6

Related Questions