1

Well, there is ; to repeat the last move in some cases. There is the . to repeat last change. But if I just did za or @a, is there a way to repeat it? I guess such a mechanism should ignore plain movements.

for example, I have a mapping such that H does o<ESC>D, or new line. If I do . , it only repeats the D. So, to do so just for defined mappings would be a start.

I am almost certain that there is no way out of the box.

  • Please dont substantially change the question once an answer is posted. you can always ask a new one. – D. Ben Knoble Jun 22 at 0:27
  • I didn't. I just added an example. I didn't intend one to provide a solution only for these cases of @reg, za. The question is to repeat any normal command. Will check repeat. Thanks. – eyal karni Jun 22 at 16:50
2

. repeats the last change, and usually does what you want (combine with e.g. cgn for a great sequence). For registers, @@ repeats the last register. @: repeats the last ex command. This is particularly handy with :normal! or :global.

For mappings, I use repeat.vim. You (and plugin authors) can have mappings take advantage of it so that . works as expected.

As you've noticed, the ft family of motions can be repeated with ,;. The only other 'repeatable' motion I'm aware of is /? searches via nN.

In general, certain commands don't have a repeatable version. For example, it doesn't make sense to have a builtin to repeat za, because (a) it's two characters ; (b) it doesn't edit text ; (c) it's easily mappable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.