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

Suggestion for vim -diff behavior change

Expand Messages
  • Josef Fortier
    I ve only really actively used diff mode recently (as opposed to using it as a visual diff tool). The default folding update on a change has led me astray more
    Message 1 of 9 , Mar 28, 2014
    • 0 Attachment
      I've only really actively used diff mode recently (as opposed to using it as a visual diff tool). The default folding update on a change has led me astray more then once.

      I've learned the workaround only today, zo and zc, but the auto-folding behavior seems to me to be a real UI issue. I believe that diff mode should:

      * leave the initial folding alone (it's quite useful)
      * leave the change markers in place (this is less important)
      * but **not** refold.

      In almost all diff resolution workflows I can imagine, we want to **review** the changes. Auto-folding assumes that we are omniscient and do not need to review.

      With the change marker keys, ]c , [c , folding is less important. I can navigate to a change set, so an ocean of text on the screen is less important. I suppose if there is a **massive** diffset (in which case vim-diff may not be the best choice) then the auto-folding behavior might be the correct behavior. But for almost all the scenarios I've been using diff-mode, the initial folding is as noise free as it needs to be.

      Keeping the change markers around also seems nice, as it facilitates review. Cycle through the changes with ]c and verify.

      Is there a way to change this behavior? Does it seem doable in vimscript?

      Anyways, it seems worth discussing. I'd like to hear any alternate views/approaches.

      --
      --
      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/d/optout.
    • Marcin Szamotulski
      ... Hi, You can easily open all folds with zr. If you want to have a wider context you can: set diffopt+=context:1000 and you should not see folding, though
      Message 2 of 9 , Mar 28, 2014
      • 0 Attachment
        On 13:53 Fri 28 Mar , Josef Fortier wrote:
        > I've only really actively used diff mode recently (as opposed to using it as a visual diff tool). The default folding update on a change has led me astray more then once.
        >
        > I've learned the workaround only today, zo and zc, but the auto-folding behavior seems to me to be a real UI issue. I believe that diff mode should:
        >
        > * leave the initial folding alone (it's quite useful)
        > * leave the change markers in place (this is less important)
        > * but **not** refold.
        >
        > In almost all diff resolution workflows I can imagine, we want to **review** the changes. Auto-folding assumes that we are omniscient and do not need to review.
        >
        > With the change marker keys, ]c , [c , folding is less important. I can navigate to a change set, so an ocean of text on the screen is less important. I suppose if there is a **massive** diffset (in which case vim-diff may not be the best choice) then the auto-folding behavior might be the correct behavior. But for almost all the scenarios I've been using diff-mode, the initial folding is as noise free as it needs to be.
        >
        > Keeping the change markers around also seems nice, as it facilitates review. Cycle through the changes with ]c and verify.
        >
        > Is there a way to change this behavior? Does it seem doable in vimscript?
        >
        > Anyways, it seems worth discussing. I'd like to hear any alternate views/approaches.
        >

        Hi,

        You can easily open all folds with zr. If you want to have a wider
        context you can:
        set diffopt+=context:1000

        and you should not see folding, though it is not the solution you ask
        for since it removes the existing folding.

        Best regards,
        Marcin
      • Chris Jones
        ... Or zR..if you have several levels of folding.. ? CJ -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the
        Message 3 of 9 , Mar 28, 2014
        • 0 Attachment
          On Fri, Mar 28, 2014 at 08:51:48PM EDT, Marcin Szamotulski wrote:

          > You can easily open all folds with zr.

          Or zR..if you have several levels of folding.. ?

          CJ

          --
          --
          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/d/optout.
        • Marcin Szamotulski
          ... In the diff mode you don t :) Regards, Marcin
          Message 4 of 9 , Mar 29, 2014
          • 0 Attachment
            On 22:38 Fri 28 Mar , Chris Jones wrote:
            > On Fri, Mar 28, 2014 at 08:51:48PM EDT, Marcin Szamotulski wrote:
            >
            > > You can easily open all folds with zr.
            >
            > Or zR..if you have several levels of folding.. ?
            >
            > CJ

            In the diff mode you don't :)

            Regards,
            Marcin
          • Justin M. Keyes
            ... I agree. The initial folding is welcome, but auto-folding after do or dp is jarring. You are talking about do/dp, right? Justin M. Keyes -- -- You
            Message 5 of 9 , Mar 29, 2014
            • 0 Attachment
              On Fri, Mar 28, 2014 at 4:53 PM, Josef Fortier <josef.fortier@...> wrote:
              > I've only really actively used diff mode recently (as opposed to using it as a visual diff tool). The default folding update on a change has led me astray more then once.
              >
              > I've learned the workaround only today, zo and zc, but the auto-folding behavior seems to me to be a real UI issue. I believe that diff mode should:
              >
              > * leave the initial folding alone (it's quite useful)
              > * leave the change markers in place (this is less important)
              > * but **not** refold.
              >
              > In almost all diff resolution workflows I can imagine, we want to **review** the changes. Auto-folding assumes that we are omniscient and do not need to review.

              I agree. The initial folding is welcome, but auto-folding after 'do'
              or 'dp' is jarring. You are talking about do/dp, right?

              Justin M. Keyes

              --
              --
              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/d/optout.
            • Josef Fortier
              @Justin: You are talking about do/dp, right? Yep! I m motivated by using fugitive for partial commits. I ve been burned a few times, so I really want to be
              Message 6 of 9 , Mar 29, 2014
              • 0 Attachment
                @Justin: You are talking about do/dp, right?

                Yep!

                I'm motivated by using fugitive for partial commits. I've been burned a few times, so I really want to be careful. The auto-folding makes it harder to confirm. zo and zc are better then what I was doing (pretty much what was suggested, but using zi instead to open all the folds).

                I've thought a bit about this, and I've come up with a partial workaround for my secondary request, keeping the markings around. Basically I've built a small compiler script to:

                * makeprg runs git diff -U1 (or the equivalent diff command)
                * errorformat parses out the file and line number.

                The line number is "wrong" in that it's the prior line, but it's pretty close. I can do a quickfix list prior to resolution and use the QF list afterwards to verify the changes.

                FWIW, I've become totally fascinated by QF in the last few week. For many years I've seen as something only for C programmers, but it's really **far** more useful, a generalized marking service, a little like ctags, but for almost anything. I've written a TAP compiler script, and found a compiler script to save and load arbitrary QF and LL lists. Other ideas, using QF to find and mark TODO's, or Documentation blocks. It seems much more generally useful and powerful then I'd understood.

                To that end, I wish the errorformat parsing wasn't so arcane. My biggest current concern is that %s auto anchors. If it was more generalized, then the integration possibilities are much greater (example, grammar checkers). I realize that the suggested fix is "use an external sed/awk script" but that seems a fragile kludge.

                --
                --
                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/d/optout.
              • Bram Moolenaar
                ... It will keep the current folds. -- Never enter the boss s office unless it s absolutely necessary. Every boss saves one corner of the desk for useless
                Message 7 of 9 , Mar 30, 2014
                • 0 Attachment
                  Justin Keyes wrote:

                  > On Fri, Mar 28, 2014 at 4:53 PM, Josef Fortier <josef.fortier@...> wrote:
                  > > I've only really actively used diff mode recently (as opposed to using it as a visual diff tool). The default folding update on a change has led me astray more then once.
                  > >
                  > > I've learned the workaround only today, zo and zc, but the auto-folding behavior seems to me to be a real UI issue. I believe that diff mode should:
                  > >
                  > > * leave the initial folding alone (it's quite useful)
                  > > * leave the change markers in place (this is less important)
                  > > * but **not** refold.
                  > >
                  > > In almost all diff resolution workflows I can imagine, we want to **review** the changes. Auto-folding assumes that we are omniscient and do not need to review.
                  >
                  > I agree. The initial folding is welcome, but auto-folding after 'do'
                  > or 'dp' is jarring. You are talking about do/dp, right?

                  So then do:
                  :set foldmethod=manual

                  It will keep the current folds.


                  --
                  Never enter the boss's office unless it's absolutely necessary. Every boss
                  saves one corner of the desk for useless assignments that are doled out like
                  Halloween candy to each visitor.
                  (Scott Adams - The Dilbert principle)

                  /// 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/d/optout.
                • Justin M. Keyes
                  ... Thanks Bram! Setting that on both of the diff windows achieves the desired effect. To do this automatically when entering Vim in diff-mode, I added this to
                  Message 8 of 9 , Mar 30, 2014
                  • 0 Attachment
                    On Sun, Mar 30, 2014 at 10:27 AM, Bram Moolenaar <Bram@...> wrote:
                    >
                    > Justin Keyes wrote:
                    >
                    >> On Fri, Mar 28, 2014 at 4:53 PM, Josef Fortier <josef.fortier@...> wrote:
                    >> > I've only really actively used diff mode recently (as opposed to using it as a visual diff tool). The default folding update on a change has led me astray more then once.
                    >> >
                    >> > I've learned the workaround only today, zo and zc, but the auto-folding behavior seems to me to be a real UI issue. I believe that diff mode should:
                    >> >
                    >> > * leave the initial folding alone (it's quite useful)
                    >> > * leave the change markers in place (this is less important)
                    >> > * but **not** refold.
                    >> >
                    >> > In almost all diff resolution workflows I can imagine, we want to **review** the changes. Auto-folding assumes that we are omniscient and do not need to review.
                    >>
                    >> I agree. The initial folding is welcome, but auto-folding after 'do'
                    >> or 'dp' is jarring. You are talking about do/dp, right?
                    >
                    > So then do:
                    > :set foldmethod=manual
                    >
                    > It will keep the current folds.

                    Thanks Bram! Setting that on both of the diff windows achieves the
                    desired effect. To do this automatically when entering Vim in
                    diff-mode, I added this to vimrc:

                    autocmd VimEnter * if &diff | exe 'windo set foldmethod=manual' | endif

                    Then, diff-mode initializes with folded text, but 'do' and 'dp' will
                    not auto-fold.

                    The Vim wiki[1] implies that &diff is set before vimrc is sourced, but
                    that isn't the case for me on Mac OS terminal Vim, nor Windows
                    terminal Vim (invoked via "vim -d a.txt b.txt").

                    [1] http://vim.wikia.com/wiki/Ignore_white_space_in_vimdiff

                    Justin M. Keyes

                    --
                    --
                    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/d/optout.
                  • Josef Fortier
                    Likewise, 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
                    Message 9 of 9 , Mar 31, 2014
                    • 0 Attachment
                      Likewise, 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/d/optout.
                    Your message has been successfully submitted and would be delivered to recipients shortly.