On Fri, February 1, 2013 06:49, Chris Lott wrote:
> I have various markdown documents with with lists contained in sections
> like so:
>
> One Section
> --------
>
> * list item 1
> * another
> * etc
>
> Second Section
> ----------
>
> * more list items
> * etc
>
> The sections are always formatted as the above (level 2 markdown
> headers); the lists are of variable length.
>
> What I need to do is figure the most efficient way to sort each list
> in each section alphabetically.
>
You can combine a :g command with the sort command, e.g. something like
this:
:g/^-\+$/+2;'}-sort
Which selects the range from just 1 line after the '----' lines
until the the last list item and sort them accordingly.
(Interestingly ':g/^-\+$/+2,'}-sort' (comma instead of semicolon)
gives an error. Not sure, why this happens).
regards,
Christian
--
--
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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Thursday, January 31, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment