Operating System - HP-UX
1755548 Members
4048 Online
108835 Solutions
New Discussion юеВ

repeat paste command in vi

 
Rob CUYNEN
Occasional Advisor

repeat paste command in vi

I have a line in a text-file that I want repeated 15 times.
So i used:
yy
15p

Didn't work only a single line was pasted.

yy
p
14.

Also didn't work, just repeats one time.


Is there anyway to do this, other than 15 times pressing p.

PS: both of the above commands work in winvi, please don't let windows beat us.
3 REPLIES 3
Paula J Frazer-Campbell
Honored Contributor

Re: repeat paste command in vi

Hi Rob

I cannot find this, meanwhile a vi doc attached.

Paula
If you can spell SysAdmin then you is one - anon
Rob CUYNEN
Occasional Advisor

Re: repeat paste command in vi

To repeat line "n" times, either yy yank and then use p "n" number of times, or mark the line as `a' and :1,ng/^/'aco'a will duplicate "n" copies of that line; e.g., :1,34g/^/'aco'a will add 34 more copies of line marked `a' ; "n" must be no greater than the number of lines in the file.

Source: http://www.jeffw.com/vi/#COPY_TEXT
Bill McNAMARA_1
Honored Contributor

Re: repeat paste command in vi

Use the period
ie .
to repeat the last vi command mode command.

Later,
Bill
It works for me (tm)