On 10/21/12 09:59, tjg wrote:
> 121021 Write about Paris with Chris @me @chris &Paris
> 121022 Phone to Inc and Gmbh @me &Inc &Gmbh
> 121029 Talk to Claire about placeholders @claire @me &Bar &Foo
>
> (in fact I do not mind what comes first, @ or &)
With your "don't mind what comes first", you can try this:
:%s/[@&]\w\+\%(\s\+[@&]\w\+\)\+$/\=join(sort(split(submatch(0))),' ')/g
which seems to do the trick for me. You can remove the "$" to let
the tags can come anywhere in the line, though it will only sort
contiguous tags, not disjoint tags.
That breaks down as
[@&]\w\+ a tagish thing
\%( make an atom but don't bother capturing it
\s\+ some whitespace
[@&]\w\+ another tagish thing
\) end of the atom
\+ one-or-more of those space+tagish pairs
It then split()s that set of tags apart on the whitespace, sort()s
the contents, then join()s it all back together with a single space
delimiting them.
-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
Sunday, October 21, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment