Operating System - HP-UX
1760485 Members
3845 Online
108894 Solutions
New Discussion юеВ

vi: repeating colon commands

 
SOLVED
Go to solution
Jon Hill_3
Advisor

vi: repeating colon commands

I'm still a bit of a newbie to vi and have a question regarding colon commands.

Let's say I want to replace any instances of "1-a" that appear on the next ten lines with "1-h." As I understand things, I would type:
:.,+10s/1-a/1-h/g
and my replace would work just fine.

Now let's say I want to repeat the above replace commandbut only for the following five lines. Is there any way for me to call up the previous text (:.,+10s/1-a/1-h/g) and change the +10 to +5, or do I have to manually retype the whole thing?
3 REPLIES 3
H.Merijn Brand (procura
Honored Contributor
Solution

Re: vi: repeating colon commands

:,+5&g

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Darren Prior
Honored Contributor

Re: vi: repeating colon commands

Hi Jon,

I don't believe there's a buffer of commands that you can edit. You can repeat some commands, but not change them as far as I know.

Perhaps macros might help you out? If these are commands you are going to use frequently then you could have them under 2 separate keys...

regards,

Darren.
Calm down. It's only ones and zeros...
H.Merijn Brand (procura
Honored Contributor

Re: vi: repeating colon commands

Some editors *do* have a buffer. In elvis and vim, you can type the colon and then the up-arrow key.

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn