RE: replace using variable
p1. I am good/p p2. You sucks!/p p3. Take that, moron/p I want to change those sentences into: p id=11. I am good/p p id=22. You sucks!/p p id=33. 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 Me personally? I'd do something like :s/\(p\)\([0-9]*\)\(. \)/p id=\2\2\3/p Ie, first field is the p, second is the index, third is the '. ' (you want to preserve the format, and not get any false hits), and replace with the new tag, and simply put back the 2nd/3rd fields.
RE: replace using variable
Hi, I have these words: p1. I am good/p p2. You sucks!/p p3. Take that, moron/p P.S. If you are feeling frustrated (Vim can do that to you), try writing something more soothing, e.g.: p1. I am happy/p p2. You are beautiful!/p p3. Take that, as a token of my love/p Heh, I thought his version was funny as all Hell. :D
Re: replace using variable
--- Akbar [EMAIL PROTECTED] wrote: Hi, I have these words: p1. I am good/p p2. You sucks!/p p3. Take that, moron/p I want to change those sentences into: p id=11. I am good/p p id=22. You sucks!/p p id=33. 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.: p1. I am happy/p p2. You are beautiful!/p p3. Take that, as a token of my love/p On Yahoo!7 Music: Create your own personalised radio station. http://au.launch.yahoo.com/