WOW  ,It works very well ! And I've learned a bit too..  Thank you, Tim,  I
guess other guy's suggestion is ok too, but I dont have much time to try
them...NOW I have to back to work ...
Thank you guys, the vim group is very nice.

Sorry, there it should be num="3" but I missed a <event > node, :P

2010/12/5 Tim Chase <[email protected]>

> On 12/04/2010 11:42 AM, Ada wrote:
>
>> I have a long xml just like this:
>>
>>     <events>
>>         <event type="normal">
>>         </event>
>>         <event type="wait" duration="10"/>
>>         <event type="normal">
>>         </event>
>>         <event type="normal">
>>         </event>
>>    ....
>>    </events>
>> Now I want to insert some number attributes just like this:
>>     <events>
>>         <event num="1" type="normal">
>>         </event>
>>         <event num="2" type="wait" duration="10"/>
>>         <event type="normal">
>>
>
> Curious why this one didn't get num="3"
>
>
>
>>         </event>
>>         <event num="3" type="normal">
>>
>
> making this one num="4"
>
>          </event>
>>    ....
>>    </events>
>>
>
> You can use
>
> :let i=0 | g/<event\>/let i+= 1 | s/<event\>\zs/\=' num="'.i.'"'
>
> This assumes that only one <event> tag will occur on a line, not
>
>  <event type="foo" /><event type="bar" />
>
> -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

Reply via email to