--- Akbar <[EMAIL PROTECTED]> wrote:
> Hi, I have these words:
>
> <p>1. I am good</p>
> <p>2. You sucks!</p>
> <p>3. Take that, moron</p>
>
> I want to change those sentences into:
> <p id="1">1. I am good</p>
> <p id="2">2. You sucks!</p>
> <p id="3">3. Take that, moron</p>
>
> How do I do that using vim replace command?
> All I can think is this:
> :%s/<p>\d/<p id="\d">\d/igc
>
> But that does not work. Any idea? Yeah, I can change them using vim
> macro or using scripting language but it will be nice if I can change
> them using vim replace command.
Hello, you're looking for backreferences:
:help /\1
You want this command:
:%s/<p>\(\d\+\)/<p id="\1">\1/igc
regards,
Peter
P.S. If you are feeling frustrated (Vim can do that to you), try writing
something more soothing, e.g.:
<p>1. I am happy</p>
<p>2. You are beautiful!</p>
<p>3. Take that, as a token of my love</p>
____________________________________________________
On Yahoo!7
Music: Create your own personalised radio station.
http://au.launch.yahoo.com/