Loading ...
Sorry, an error occurred while loading the content.
 

Sorting multiple "sections"

Expand Messages
  • Chris Lott
    I have various markdown documents with with lists contained in sections like so: One Section ... * list item 1 * another * etc Second Section ... * more list
    Message 1 of 5 , Jan 31 9:49 PM
      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.

      Thoughts?

      c
      --
      Chris Lott <chris@...>

      --
      --
      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@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Christian Brabandt
      ... You can combine a :g command with the sort command, e.g. something like ... Which selects the range from just 1 line after the ---- lines until the the
      Message 2 of 5 , Jan 31 10:40 PM
        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@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Paul
        ... Where’s the “-” in “-sort” documented? Ie. How did you know you could do that? :) -- . -- -- You received this message from the vim_use
        Message 3 of 5 , Feb 7, 2013
          On Friday, 01 February, 2013 at 06:40:44 GMT, Christian Brabandt wrote:
          >> 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

          Where’s the “-” in “-sort” documented? Ie. How did you know you could do that? :)

          --

          .

          --
          --
          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@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Marcin Szamotulski
          ... It is documented under ... see the first paragraph under the list on which you land with the above command. Best, Marcin -- -- You received this message
          Message 4 of 5 , Feb 7, 2013
            On 10:58 Thu 07 Feb , Paul wrote:
            > On Friday, 01 February, 2013 at 06:40:44 GMT, Christian Brabandt wrote:
            > >> 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
            >
            > Where’s the “-” in “-sort” documented? Ie. How did you know you could do that? :)
            >
            > --
            >
            > .
            >
            > --
            > --
            > 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@....
            > For more options, visit https://groups.google.com/groups/opt_out.
            >

            It is documented under
            :help :range
            see the first paragraph under the list on which you land with the above
            command.

            Best,
            Marcin

            --
            --
            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@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • Paul
            ... Ah, I see. Thanks. -- . -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying to.
            Message 5 of 5 , Feb 7, 2013
              On Thursday, 07 February, 2013 at 11:19:02 GMT, Marcin Szamotulski wrote:
              >> >You can combine a :g command with the sort command, e.g. something like
              >> >this:
              >> >:g/^-\+$/+2;'}-sort
              >>
              >> Where’s the “-” in “-sort” documented? Ie. How did you know you could do that? :)
              >
              >It is documented under
              > :help :range
              >see the first paragraph under the list on which you land with the above
              >command.

              Ah, I see. Thanks.

              --

              .

              --
              --
              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@....
              For more options, visit https://groups.google.com/groups/opt_out.
            Your message has been successfully submitted and would be delivered to recipients shortly.