Wednesday, September 2, 2009

how to re-use the pattern matched in parenthes

Hi,

How do I re-use the pattern matched in parentheses? Let say there are
two lines as below.

abc(123);
xyz
.
.
.
abc(245);
well;


I have to match lines with the pattern abc(.*) and also need to
capture the string in parentheses and then
create a new line below the matched line, the new line contains the
string matched in parentheses.

like below

abc(123);
123
xyz
.
.
abc(245)
245
well

How do I achieve this?

I have the below in this mind..but how do I go further?

:g/abc(\(.\+\))/normal o


I hope my question is clear.

Thanks,
Sharat
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

No comments:

Post a Comment