>>> AAAA    BB    CCCCCC
>>>
>>> Must be come
>>>
>>> CCCCCC  AAAA  BB
>> :g/^AAAA/s/^.*$/\=split(submatch(0))[-1].'  
>> '.join(split(submatch(0))[0:-2],'  ')
> 
> 
> How do you change the above solution when you want
> AAAA    BB    CCCCCC
> 
> to be changed into
> 
> AAAA   CCCCCC   BB


I'd tag the constituent parts and then reorder them as desired:

   :%s/\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)/\1 \3 \2/

Each of the \(\S\+\) captures one group of one-or-more ("\+") 
non-whitespace characters ("\S") saving each captured item as \1, 
\2, and \3.  You can then reorder them in the replacement by 
back-referencing those groups...in your original case, the 
replacement would be "\3 \1 \2", and in the 2nd case, your 
replacement is "\1 \3 \2"

-tim




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

Reply via email to