If you can write a regex that matches the first lines, I've posted a "somewhat brutish" method for doing the sort in the past:
https://groups.google.com/forum/#!searchin/vim_use/sort$20John$20Little/vim_use/EHULejNIHz4/p9Dh6IILRtMJ (If your chunks are long, tread carefully with :set ul=-1). It's a variation on the decorate-sort-undecorate method. If your first lines aren't distinctive other than being preceded by an empty line, I found I had to do two decorate steps, and other fiddling: :normal ggO " start file with blank line, so that the first " first line has a blank line before it :g/\(^\n\)\@<=./s/$/xyzzy " mark first lines :v/xyzzy/s/$/plugh/ " mark the others :1dd " delete the added line :g/plugh/-j! " join non-first lines to the one before it :sort :%s/plughplugh/\r/g " split lines again :%s/plugh/\r/g :%s/xyzzy/\r/g To sort the chunks randomly, you'd have to decorate the lines with a random number. If you're on something Gnu-ish, piping through shuf would do; replace the :sort with :%!shuf Regards, John Little -- -- 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 [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
