Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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!
Hello
Hello
Hello

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
1  
I'd assume you could also do 3@a to repeat the macro multiple times –  redEvo Apr 19 '12 at 18:34
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.