repeat append command N times

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

repeat append command N times

Ulrich Leopold
Dear all,

I would like to append a line and repeat that several times in either vim or sed.
Something like:

:50a\blablabla 4444 555               ## 50 times (in vim)
sed '50a\blablabla 4444 555' test.txt ## 50 times (in sed)

any idea how to do that? The above examples do not work.

Ulrich

Reply | Threaded
Open this post in threaded view
|

Re: repeat append command N times

Dominic Evans
qq
a\blablabla 4444 555<CR>
50@q

On 21/09/05, Ulrich Leopold <[hidden email]> wrote:

> Dear all,
>
> I would like to append a line and repeat that several times in either vim or sed.
> Something like:
>
> :50a\blablabla 4444 555               ## 50 times (in vim)
> sed '50a\blablabla 4444 555' test.txt ## 50 times (in sed)
>
> any idea how to do that? The above examples do not work.
>
> Ulrich
>
>
Reply | Threaded
Open this post in threaded view
|

Re: repeat append command N times

Tim Chase-2
In reply to this post by Ulrich Leopold
> I would like to append a line and repeat that several times in
> either vim or sed.  Something like:
>
> :50a\blablabla 4444 555               ## 50 times (in vim)
> sed '50a\blablabla 4444 555' test.txt ## 50 times (in sed)
>
> any idea how to do that? The above examples do not work.

The first one could be (in normal mode)

        50o\blablahblah 4444 555

Your first one is an Ex command where the "50" is interpreted as
the line number rather than a count, so you end up appending your
text after line 50. Same thing with your sed command.

-tim





Reply | Threaded
Open this post in threaded view
|

Re: repeat append command N times

Tim Chase-2
In reply to this post by Dominic Evans
> qq
> a\blablabla 4444 555<CR>
> 50@q

Just a small caveat...this will perform the action 51 times (the
original time + the 50 repetitions).

-tim





Reply | Threaded
Open this post in threaded view
|

Re: repeat append command N times

Dominic Evans
Good caveat :) wasn't thinking

On 21/09/05, Tim Chase <[hidden email]> wrote:

> > qq
> > a\blablabla 4444 555<CR>
> > 50@q
>
> Just a small caveat...this will perform the action 51 times (the
> original time + the 50 repetitions).
>
> -tim
>
>
>
>
>
>