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

Bug in formatting of nested comments?

Expand Messages
  • Gary Johnson
    Given a vim session started with vim -N -u NONE and the following settings: set formatoptions=rntcql set comments=n: ,fb:- set ai set sw=4 set tw=40 ... 1.
    Message 1 of 3 , Sep 2, 2003
    • 0 Attachment
      Given a vim session started with

      vim -N -u NONE

      and the following settings:

      set formatoptions=rntcql
      set comments=n:>,fb:-
      set ai
      set sw=4
      set tw=40

      and containing the following lines:

      ------------------------------------------------------------------------
      1. The quick brown fox jumped over the lazy dog's back.

      - The quick brown fox jumped over the lazy dog's back.

      > 1. The quick brown fox jumped over the lazy dog's back.
      >
      > - The quick brown fox jumped over the lazy dog's back.
      ------------------------------------------------------------------------

      executing 'gggqG' results in the lines/paragraphs being reformatted
      like this:

      ------------------------------------------------------------------------
      1. The quick brown fox jumped over the
      lazy dog's back.

      - The quick brown fox jumped over the
      lazy dog's back.

      > 1. The quick brown fox jumped over
      > the lazy dog's back.
      >
      > - The quick brown fox jumped over
      > the lazy dog's back.
      ------------------------------------------------------------------------

      The problem is that vim ignores the list item tags at the beginning
      of those lines when they are in quoted lines. I don't know if this
      is a bug or a missing feature, but since vim recognizes paragraphs
      within such quoted regions, and even nested quoted regions, it would
      be nice if it also recognized these special paragraph types within
      quoted regions.

      Gary

      --
      Gary Johnson | Agilent Technologies
      garyjohn@... | Wireless Division
      | Spokane, Washington, USA
    • Klaus Bosau
      ... Not as powerful as an inbuilt solution, but maybe helpful in certain situations.. Strip the comment leader referred to prior to applying gq and insert it
      Message 2 of 3 , Sep 4, 2003
      • 0 Attachment
        On Tue, 2 Sep 2003, Gary Johnson wrote:

        > [...]
        >
        > The problem is that vim ignores the list item tags at the beginning of
        > those lines when they are in quoted lines. I don't know if this is
        > a bug or a missing feature, but since vim recognizes paragraphs within
        > such quoted regions, and even nested quoted regions, it would be nice
        > if it also recognized these special paragraph types within quoted
        > regions.

        Not as powerful as an inbuilt solution, but maybe helpful in certain
        situations.. Strip the comment leader referred to prior to applying 'gq'
        and insert it again afterwards..

        vn ,gq <Esc>'<0yl:'<,'>s/^.//<Cr>'[gq']:'<,.s/^/\=@"/<Cr>

        Klaus
      • Gary Johnson
        ... Nice! Thank you! I always learn a lot from reading these mappings, too. I did make one change to preserve the right margin: instead of deleting the
        Message 3 of 3 , Sep 4, 2003
        • 0 Attachment
          On 2003-09-04, Klaus Bosau <kbosau@...> wrote:
          > On Tue, 2 Sep 2003, Gary Johnson wrote:
          >
          > > [...]
          > >
          > > The problem is that vim ignores the list item tags at the beginning of
          > > those lines when they are in quoted lines. I don't know if this is
          > > a bug or a missing feature, but since vim recognizes paragraphs within
          > > such quoted regions, and even nested quoted regions, it would be nice
          > > if it also recognized these special paragraph types within quoted
          > > regions.
          >
          > Not as powerful as an inbuilt solution, but maybe helpful in certain
          > situations.. Strip the comment leader referred to prior to applying 'gq'
          > and insert it again afterwards..
          >
          > vn ,gq <Esc>'<0yl:'<,'>s/^.//<Cr>'[gq']:'<,.s/^/\=@"/<Cr>

          Nice! Thank you! I always learn a lot from reading these mappings,
          too. I did make one change to preserve the right margin: instead
          of deleting the comment leader, I replaced it with a space.

          vn ,gq <Esc>'<0yl:'<,'>s/^./ /<Cr>'[gq']:'<,.s/^ /\=@"/<Cr>

          Regards,
          Gary

          --
          Gary Johnson | Agilent Technologies
          garyjohn@... | Wireless Division
          | Spokane, Washington, USA
        Your message has been successfully submitted and would be delivered to recipients shortly.