epanda wrote:
> HI,
> 
> I have this content :
> 
> <ds te="DMoat"><ppe id="GE" nerty="xml" ></ppe></ds>
> <ds te="DMoat"><ppe id="GE" nerty="CXML" ></ppe></ds>
> <ds te="DMoat"><ppe id="GE" nerty="SXML" ></ppe></ds>
> 
> Each begin of lines is the same. Only nerty attribute is different.
> 
> I wanna have this content :
> 
> <ds te="DMoat">
>   <ppe id="GE" nerty="xml" ></ppe>
>   <ppe id="GE" nerty="CXML" ></ppe>
>   <ppe id="GE" nerty="SXML" ></ppe>
> </ds>
> 
> How can I do this tranformation ?

While I can't come up with a nice all-in-one solution, it is 
possible assuming the file is sorted so all the <ds te="xxx"> 
items are grouped by "xxx".  Run the following until it says 
there are no more replacements to take care of moving the <ds> 
elements outside their collected stuff:

  :%...@\(<ds te="[^"]*">\)\(\_.\{-}\)</ds>\_s\...@\1\r\2\r@g

Then run the following 3 commands:

   :%s@</ds>@\r&@g
   :v/</d
   :g/^<ppe/sil! >

The 1st one puts the closing "</ds>" on its own line, the 2nd one 
removes the spurious whitespace that was added in the process, 
and the 3rd one indents the "<ppe>" tags by one 'shiftwidth' 
(using tabs or spaces based on your 'expandtab' setting)

-tim






--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to