On 19/04/11 04:50, googler wrote:
Hi,

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
(which I did for "-new_net_name ${eco_prefix}_net_xxx"). I know about
the increment operation (CTRL-A) in vim but not sure to use it in this
context. Any idea how this can be done easily (using CTRL-A or
otherwise)? I am sure there are different ways of doing this, so all
suggestions (not just the best or shortest one) are very welcome as
they might help me understand several different features of vim
through one example.

Thanks!


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 ...
insert_buffer -new_net_name ${eco_prefix}_net_003 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_004 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_005 -new_cell_name $
{eco_prefix}_001 ...


## rx_clk32
insert_buffer -new_net_name ${eco_prefix}_net_006 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_007 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_008 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_009 -new_cell_name $
{eco_prefix}_001 ...


## tx_clk32
insert_buffer -new_net_name ${eco_prefix}_net_010 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_011 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_012 -new_cell_name $
{eco_prefix}_001 ...


## txck312
insert_buffer -new_net_name ${eco_prefix}_net_013 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_014 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_015 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_016 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_017 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_018 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_019 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_020 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_021 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_022 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_023 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_024 -new_cell_name $
{eco_prefix}_001 ...
insert_buffer -new_net_name ${eco_prefix}_net_025 -new_cell_name $
{eco_prefix}_001 ...


Maybe use a substitute with \zs\d\+\ze in the middle of a well-chosen pattern to isolate the number you want to replace, and see ":help sub-replace-expression" about evaluating a formula to compute what to replace it by?

see
        :help /\zs
        :help /\d
        :help /\+
        :help /\ze
        :help sub-replace-expression
        :help line()


Best regards,
Tony.
--
                Answers to Last Fortune's Questions:

(1) None.  (Moses didn't have an ark).
(2) Your mother, by the pigeonhole principle.
(3) I don't know.
(4) Who cares?
(5) 6 (or maybe 4, or else 3).  Mr. Alfred J. Duncan of Podunk,
    Montana, submitted an interesting solution to Problem 5.
(6) There is an interesting solution to this problem on page 1029 of my
    book, which you can pick up for $23.95 at finer bookstores and
    bathroom supply outlets (or 99 cents at the table in front of
    Papyrus Books).

--
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

Reply via email to