Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've noticed vim can be pretty intuitive, but I'm having trouble finding a way to repeat the second-to-last command (or third-to-last, fourth-to-last, etc.). By typing . in normal mode it will repeat the last command. Pressing 3. will repeat the last command three times.

Let's say I type oHello<Esc> then A, World!<Esc>. I now get

Hello, World!

on the screen. Now, say I want to get

Hello, World!

without typing Hello. Does vim store the history beyond one command, so I could type something like 3,2. (i.e. repeat the second-to-last command three times)?

share|improve this question
Remember you can record anything as a macro (qaoHello<esc>q then @a to repeat Hello whenever you want.) There's also @@ to repeat the last used macro. – James McLaughlin Apr 19 '12 at 18:17
I'd assume you could also do 3@a to repeat the macro multiple times – redbmk Apr 19 '12 at 18:34
up vote 4 down vote accepted

No, the . command in vim does not have a history, nor is there any sort of repeat history for normal mode commands that I am aware of. For the fewest number of keystrokes, I'd recommend 4oHello<Esc>3jA, World<Esc>. If you've already done oHello<Esc>A, World<Esc>, you could follow that with uyy<Ctrl-r>3p.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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