Repeat Last Normal Mode Command, Including Moves, in Vim

Repeat Last Normal Mode Command, Including Moves, in Vim

In Vim, with ., I can repeat the last normal mode command; for example:

dd.

deletes a line twice.
But, if I type

5j.

the cursor does't move 10 lines down. How do I repeat the last normal mode command, especially a move?

1

5 Answers

it's doable even in vanilla vim, but applicability depends on your use case, ie. how often you'll need to repeat it, since it requires few more keystrokes to make it repeatable.


Option 1: turn it into a command mode operation

using moving down 5 lines as example, you can do:

  1. enter :norm 5j, it'll move the cursor down 5 lines
  2. use @: to repeat the movement

:norm stands for normal, any following string is regarded as your keystrokes under normal mode


Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.