In Vim, with
., I can repeat the last normal mode command; for example:
deletes a line twice.
But, if I type
the cursor does't move 10 lines down. How do I repeat the last normal mode command, especially a move?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
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.
using moving down 5 lines as example, you can do:
:norm 5j, it'll move the cursor down 5 lines
@:to repeat the movement
:norm stands for normal, any following string is regarded as your keystrokes under normal mode
qa(store macro into register
a, you can pick your own register like
q(finish recording macro)
@ato repeat your recorded operation (replace
awith the register name you picked, eg.
macro requires more spiritual power to set up but it's more repeatable in the sense that you can store multiple operations in different registers without being overriden by latest operations.
vim doesn't do this unfortunately. The best you can do is install the repmo.vim plugin, which repeats movement commands that have a count.