[Linux-disciples] Sorting lines matching a pattern
Stephen R Laniel
steve at laniels.org
Sun Jul 24 23:19:36 EDT 2005
On Sun, Jul 24, 2005 at 11:11:16PM -0400, Chung-chieh Shan wrote:
> :g/^\*/.,/^\($\|[^*]\)/-1!sort
That is perhaps the world's most info-dense haiku.
Let me see if I can parse this. (Vi is intended for
efficiency, not clarity.)
1) Select all those lines matching '^\*'.
2) On the matching lines, select from the current line ('.')
up to either the last line of the document ('$') or the
first line that doesn't match '^\*'.
3) With those lines selected, sort them. But what's the '-1'
about? Does that mean 'back up one line'?
This method doesn't generalize to documents formatted like
so, does it?
* Some stuff
[blank line]
* Some other stuff
[blank line]
I'm still working on parsing. Thanks, Ken.
--
Stephen R. Laniel
steve at laniels.org
+(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20050724/19cab467/attachment.pgp
More information about the Linux-disciples
mailing list