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

Re: Consider lines containing a tab a paragraph boundary

Expand Messages
  • Bram Moolenaar
    ... Hmm, I think what we really want is to match the text from the end of one paragraph until the start of the next one. The example with /^$ would still
    Message 1 of 18 , Apr 24, 2013
    • 0 Attachment
      Christian Brabandt wrote:

      > On Sa, 20 Apr 2013, Bram Moolenaar wrote:
      >
      > > I wonder if changing 'paragraphs' and 'sections' into a regexp that
      > > matches at what's between paragraphs is sufficient. How about this
      > > style with two paragraphs:
      >
      > Did this and updated the example. Would this be acceptable?

      Hmm, I think what we really want is to match the text from the end of
      one paragraph until the start of the next one. The example with "/^$"
      would still work to have empty-line separated paragraphs. Paragraphs
      that start with an indent would be found with "/^\s\+".

      You could then also allow more than one empty line between paragraphs
      with "/^\n*$".

      I haven't tried the code, perhaps it already works like that?


      --
      I noticed my daughter's Disney-net password on a sticky note:
      "MickeyMinnieGoofyPluto". I asked her why it was so long.
      "Because they say it has to have at least four characters."

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ an exciting new programming language -- http://www.Zimbu.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --
      --
      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
      ... matches at what s between paragraphs is sufficient. How about this ... one paragraph until the start of the next one. The example with /^$ would still
      Message 2 of 18 , Apr 24, 2013
      • 0 Attachment
        On Wed, April 24, 2013 11:38, Bram Moolenaar wrote:
        > Christian Brabandt wrote:
        >> On Sa, 20 Apr 2013, Bram Moolenaar wrote:
        >> > I wonder if changing 'paragraphs' and 'sections' into a regexp that
        matches at what's between paragraphs is sufficient. How about this
        style with two paragraphs:
        >> Did this and updated the example. Would this be acceptable?
        > Hmm, I think what we really want is to match the text from the end of
        one paragraph until the start of the next one. The example with "/^$"
        would still work to have empty-line separated paragraphs. Paragraphs
        that start with an indent would be found with "/^\s\+".

        correct.

        > You could then also allow more than one empty line between paragraphs
        with "/^\n*$".

        That would be possible, but doesn't really change the cursor motion. Take
        the example from the patch:
        ----------------------------
        1 Lorem ipsum dolor sit amet,
        2 consetetur sadipscing elitr,
        3 sed diam
        4
        5
        6 Lorem ipsum dolor sit amet,
        7 consetetur sadipscing elitr,
        8 sed diam

        If the 'para' option is set to '/^$' moving using '}' will first move to
        line 4, the next paragraph motion will move to line 5. Typing '}' again
        will then move the cursor at the end of the last line.
        --------------------------

        Even is you use the /^\n\+$ as regular expression, the cursor will still
        jump to the exact same positions, as line 4 and line 5 match
        that regular expression. We could make it jump to the end of the match
        using the SEARCH_END flag and then advance the cursor one more position,
        but this would only work on forward searches, this doesn't seem to work
        for backward searches:
        https://groups.google.com/group/vim_use/msg/d82897dd34010e93?hl=de

        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.
      • Bram Moolenaar
        ... The } motion is a bit strange in that it stops before a paragraph. I never understood why it s like that and not jumping to the first line of the
        Message 3 of 18 , Apr 24, 2013
        • 0 Attachment
          Christian Brabandt wrote:

          > On Wed, April 24, 2013 11:38, Bram Moolenaar wrote:
          > > Christian Brabandt wrote:
          > >> On Sa, 20 Apr 2013, Bram Moolenaar wrote:
          > >> > I wonder if changing 'paragraphs' and 'sections' into a regexp
          > >> > that matches at what's between paragraphs is sufficient. How
          > >> > about this style with two paragraphs:
          > >> Did this and updated the example. Would this be acceptable?
          > > Hmm, I think what we really want is to match the text from the end
          > > of one paragraph until the start of the next one. The example with
          > > "/^$" would still work to have empty-line separated paragraphs.
          > > Paragraphs that start with an indent would be found with "/^\s\+".
          >
          > correct.
          >
          > > You could then also allow more than one empty line between paragraphs
          > with "/^\n*$".
          >
          > That would be possible, but doesn't really change the cursor motion. Take
          > the example from the patch:
          > ----------------------------
          > 1 Lorem ipsum dolor sit amet,
          > 2 consetetur sadipscing elitr,
          > 3 sed diam
          > 4
          > 5
          > 6 Lorem ipsum dolor sit amet,
          > 7 consetetur sadipscing elitr,
          > 8 sed diam
          >
          > If the 'para' option is set to '/^$' moving using '}' will first move to
          > line 4, the next paragraph motion will move to line 5. Typing '}' again
          > will then move the cursor at the end of the last line.

          The } motion is a bit strange in that it stops before a paragraph. I
          never understood why it's like that and not jumping to the first line of
          the paragraph.

          Anyway, using ]] and [[ you do jump to the start or end of a section, so
          there it's easier to see what the pattern does.

          > Even is you use the /^\n\+$ as regular expression, the cursor will still
          > jump to the exact same positions, as line 4 and line 5 match
          > that regular expression. We could make it jump to the end of the match
          > using the SEARCH_END flag and then advance the cursor one more position,
          > but this would only work on forward searches, this doesn't seem to work
          > for backward searches:
          > https://groups.google.com/group/vim_use/msg/d82897dd34010e93?hl=de

          How about using the pattern /^\n\+\zs ? The \zs marks where the cursor
          ends up. This also allows moving to the first line of the paragraph.

          Question remains how to handle {, where the cursor ends up then.
          An alternative is to use flags after // to specify where the cursor is
          positioned for { and }, e.g. /^\n\+/{s}e would mean { moves to the
          start of the match and } to the end of the match.


          --
          hundred-and-one symptoms of being an internet addict:
          217. Your sex life has drastically improved...so what if it's only cyber-sex!

          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          \\\ an exciting new programming language -- http://www.Zimbu.org ///
          \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

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