On Aug 4, 4:22 pm, Jim Green <[email protected]> wrote:
> Hi,
>
> I have as section
>
> sectionA
> service=1
> network=1.1.1.1
>
> and I want to add sections to make it like
>
> sectionA
> service=1
> network=1.1.1.1
>
> sectionB
> service=2
> network=1.1.1.2
>
> sectionC
> service=3
> network=1.1.1.3
> ...
> until
> sectionZ
> service=26
> network=1.1.1.26
>
> Could anyone point me how to do this in vim? I thought of using shell
> scripts to do it but might be an overkill,
> Thanks!
> Jim

I'd use a recording (:help q) and incrementing (:help ctrl-a)

So starting with cursor on line one of a file with four lines,
your sectionA followed by a blank line, type
qq (start recording)
4yy (yank four lines)
4j (move down four lines)
p (paste)
$ (go to end of line)
ctrl-A (increment)
j (down one line)
$
ctrl-A
j
$
ctrl-A
2k (up two lines)
q (stop recording)

At this point you have done sectionB

2...@q (play back recording 24 times to get up to Z)

regards,
Geoff

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to