On Apr 18, 8:23 pm, Tim Chase <[email protected]> wrote: > On 04/18/2011 09:50 PM, googler wrote: > > > I have a few lines as below. Most of the lines below correspond to a > > number (starting from 001 and counting upward). I want to change the > > part "-new_cell_name ${eco_prefix}_001 " in each line to its > > corresponding number without having to go to each line and type it > > > insert_buffer -new_net_name ${eco_prefix}_net_001 -new_cell_name $ > > {eco_prefix}_001 ... > > insert_buffer -new_net_name ${eco_prefix}_net_002 -new_cell_name $ > > {eco_prefix}_001 ... > > I'd just do a substitute across the lines so that you snag the > first number and replace it as the second number. Something like > > :%s/${eco_prefix}_net_\(\d\d\d\) -new_cell_name > ${eco_prefix}_\zs\d\d\d/\1 > > The "\zs" makes the replacement start at that point, and the > "\(...\)" captures the first portion to be used in the > replacement "\1". > > -tim
This is what I actually used after posting the question. But I was wondering if there is a better way. In this case, I had already changed the first numbers manually, so I could use that to replace the second number in the same line. But is there a way where even if I had not changed the first number, I could change both the first and second numbers in a line to the same value (which is one more than the number used in the line above)? Thanks. -- 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
