Thursday, December 24, 2009

Dupicate and increment lines

Hi,

Goal : multiply some parts of lines which contain factors

foo(2)bar(9)

Should become

foo1bar1
foo1bar2
foo1bar3
foo1bar4
foo1bar5
foo1bar6
foo1bar7
foo1bar8
foo1bar9
foo2bar1
foo2bar2
foo2bar3
foo2bar4
foo2bar5
foo2bar6
foo2bar7
foo2bar8
foo2bar9


I have done a func that receive (foo,2,bar,9) but it take 0.0008
second.
In fact I have more than 2000 lines with this format : foo(2)bar(9)
or other possible cases

foobar
foo(X)bar
foobar(Y)
foo(X)bar(Y)

foo(X)bar(Y)foo(Z)
foobar(Y)foo(Z)
foo(X)barfoo(Z)
foo(X)bar(Y)foo
foobar(Y)foo


Have you got another way to improve instead of doing
g/\([^(]\)\((\d\+)\)....../\=myFunc(submatch(1) etc...)/

Thanks

g/

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

No comments:

Post a Comment