On 2013-08-07 18:58, Eric Siegel wrote: > I want to convert lines like this: > > value1|value2|value3 > > into: > > def foo(x="value1" > y="value2" > z="value3") > > But I ran into a problem when trying to apply this function to a > range. The range gets confused because I am appending additional > lines. [snip] > Is there not some helper method that knows how to append using > ranges
I know that using a :g command notes the first/last lines of the range specified as well as marking the already-processed lines. You don't provide the exact specifications of your transformation (are there always 3 items separated by pipes? does "foo" ever change? does indentation change based on a changing function-name?) However, a simple transformation can be done with :%s/\(.*\)|\(.*\)|\(.*\)/def foo(x="\1"\r y="\2"\r z="\3") which should work for any range you pass it (in the above example, the whole file, but could just as easily be any Ex range). -tim -- -- 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 --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
