This is the exact command I used long ago but forgotten about.
Specifically I forgot about submatch(), and I thought \= was the
correct thing to use, but when I ran :h \= it was about something else
and I became unsure.
Thanks.
--MZ
On Nov 20, 12:52 pm, Ulrich Mueller <[EMAIL PROTECTED]
chemnitz.de> wrote:
> To sort words within double quoted texts, try:
>
> :%s/"\zs[^"]*\ze"/\=join(sort(split(submatch(0))))/g
>
> On Thu, 20 Nov 2008, A. S. Budden wrote:
>
> > How about:
>
> > :g/str_list/let items = sort(copy(split(matchlist(getline('.'),
> > '"\([^"]*\)"')[1], ' \+'))) | s/"\zs[^"]*\ze"/\=join(items, ' ')
>
> > ...
>
> > 2008/11/20 MZ <[EMAIL PROTECTED]>:
>
> >> suppose I have a few line that goes like this:
> >> str_list="foo bar man act"
>
> >> how can I sort all the words within the quote " ... " so that it
> >> becomes "act bar foo man"? It is okay to eliminate extra whitespace so
> >> that it ends up with only one space behind each word.
>
> >> --MZ
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---