Sunday, February 9, 2014

Re: sorting/randomizing text blocks separated by empty lines

Chris Lott wrote:
> Given a document with text blocks separated by empty lines:
>
> ```
> foo
> chunk one
>
> bar
> chunk two
>
> baz
> chunk three
> ```
>
> I need to both (for different purposes) 1) sort the blocks by their
> first lines and then 2) randomize the blocks by their first line.
>
> How might one (I) do this?
>
You could try using my vissort plugin
(http://www.drchip.org/astronaut/vim/index.html#VISSORT). It contains a
function, BlockSort, which will sort blocks of text. From its help:

:'<,'>BS
:'< '>BS nextblock endblock findtag tagpat tagsub
:[range]call BlockSort(nextblock,endblock,findtag,tagpat,tagsub)
:[range]call BlockSort(...)

If any arguments are missing, BlockSort()
will query the user for them.

This function's purpose is to sort blocks of text based on tags
contained within the blocks.

To do a randomization, you'd need to prepend/append randomized tags for
BlockSort to work with.

Regards,
C Campbell

--
--
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.

No comments: