On 12/04/2010 12:42 PM, 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">

         </event>
         <event num="3" type="normal">

         </event>
    ....
    </events>
I know VIM must can do that work,but HOW? Thanks a lot, By the way,
though I'm a newbie of VIM,but I really love it ...



I would do this by making a recording that searches for a pattern,
pastes, increments the number using ctrl-a shortct, then yanks the
string.

see :help q
Something like (untested): (first yank the string)
q/\<event<enter>epf"l<ctrl-a>F<space>yEq

then @q to test it, 2...@q to run it 20 times or whatever you need.

I like to use recordings because you're using normal commands you
always use, so I don't need to look things up in help first.

 -ak

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