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

vimdiff: how to ignore all same lines and show ONLY diff lines?

Expand Messages
  • ping
    exports: by default vimdiff will not only show the diff lines, but also show a couple of same lines to give you a sense of context. how to suppress all same
    Message 1 of 7 , Dec 7, 2012
    • 0 Attachment
      exports:
      by default vimdiff will not only show the diff lines, but also show a
      couple of same lines to give you a sense of context.
      how to suppress all same lines and display only those diff lines?

      regards
      ping

      --
      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
    • Tony Mechelynck
      ... see ... Best regards, Tony. -- If you push the extra ice button on the soft drink vending machine, you won t get any ice. If you push the no ice
      Message 2 of 7 , Dec 7, 2012
      • 0 Attachment
        On 08/12/12 05:50, ping wrote:
        > exports:
        > by default vimdiff will not only show the diff lines, but also show a
        > couple of same lines to give you a sense of context.
        > how to suppress all same lines and display only those diff lines?
        >
        > regards
        > ping
        >
        see
        :help 'diffopt' " context:{n}
        :help fold-diff


        Best regards,
        Tony.
        --
        If you push the "extra ice" button on the soft drink vending machine,
        you won't get any ice. If you push the "no ice" button, you'll get
        ice, but no cup.

        --
        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
      • Roy Fulbright
        ... Add the following line to .vimrc:set diffopt=filler,context:0 -- You received this message from the vim_use maillist. Do not top-post! Type your reply
        Message 3 of 7 , Dec 7, 2012
        • 0 Attachment
          > Date: Fri, 7 Dec 2012 23:50:17 -0500
          > From: songpingemail@...
          > To: vim_use@...
          > Subject: vimdiff: how to ignore all same lines and show ONLY diff lines?
          >
          > exports:
          > by default vimdiff will not only show the diff lines, but also show a
          > couple of same lines to give you a sense of context.
          > how to suppress all same lines and display only those diff lines?
          >
          > regards
          > ping
          >
          > --
          > 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

          Add the following line to .vimrc:
          set diffopt=filler,context:0
           

          --
          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
        • ping
          ... lines? ... thanks Roy (and Tony), that really works! now I still feel that is a big weak comparing to what I wanted achieve: say I have these 2 captures
          Message 4 of 7 , Dec 7, 2012
          • 0 Attachment
            On 12/8/2012 12:20 AM, Roy Fulbright wrote:
            > > Date: Fri, 7 Dec 2012 23:50:17 -0500
            > > From: songpingemail@...
            > > To: vim_use@...
            > > Subject: vimdiff: how to ignore all same lines and show ONLY diff lines?
            > >
            > > exports:
            > > by default vimdiff will not only show the diff lines, but also show a
            > > couple of same lines to give you a sense of context.
            > > how to suppress all same lines and display only those diff lines?
            > >
            > > regards
            > > ping
            > >
            > > --
            > > 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
            >
            > Add the following line to .vimrc:
            > set diffopt=filler,context:0
            >
            > --
            > 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



            thanks Roy (and Tony), that really works!

            now I still feel that is a big weak comparing to what I wanted achieve:

            say I have these 2 captures from the devices:

              Multicast routing enabled               Multicast routing enabled                                                   
              Use Framed Routes = disabled                    Use Framed Routes = disabled                                                

              In Received Packets 10, Bytes 1000              In Received Packets 15, Bytes 150                                           
                Unicast Packets 10, Bytes 1000                  Unicast Packets 15, Bytes 150                                             
                Multicast Packets 0, Bytes 0                    Multicast Packets 1, Bytes 54                                             
              In Policed Packets 0, Bytes 0                   In Policed Packets 0, Bytes 0                                               
              In Error Packets 0                              In Error Packets 0                                                          
              In Invalid Source Address Packets 0             In Invalid Source Address Packets 0                                         
              In Discarded Packets 0                          In Discarded Packets 0                                                      
              Out Forwarded Packets 100, Bytes 10000          Out Forwarded Packets 150, Bytes 15000                                      
                Unicast Packets 100, Bytes 10000                Unicast Packets 150, Bytes 15000                                          
                Multicast Routed Packets 0, Bytes 0             Multicast Routed Packets 0, Bytes 0                                       
              Out Scheduler Dropped Packets 0, Bytes 0        Out Scheduler Dropped Packets 0, Bytes 0                                    
              Out Policed Packets 0, Bytes 0                  Out Policed Packets 0, Bytes 0                                              
              Out Discarded Packets 0                         Out Discarded Packets 0                                                     



            with above solution now I can focus on lines with an increased counter(s).
            But quite often I need to manually calculate the "delta" amount of those counters.
            so instead of just mark the diff lines, ideally if I can have the 2nd diff window displaying only the delta of those counters whenever there is any difference

            29   In Received Packets 10, Bytes 1000          29   In Received Packets 5, Bytes 500         
            30     Unicast Packets 10, Bytes 1000                   30     Unicast Packets 5, Bytes 500           
            31     Multicast Packets 0, Bytes 0                     31     Multicast Packets 1, Bytes 54          
            32 +--  4 lines: In Policed Packets 0, Bytes 0          32 +--  4 lines: In Policed Packets 0, Bytes 0
            36   Out Forwarded Packets 100, Bytes 10000             36   Out Forwarded Packets 50, Bytes 5000     
            37     Unicast Packets 100, Bytes 10000                 37     Unicast Packets 50, Bytes 5000         

            I don't find existing functions/scripts (say script 3745 or 3075) can do that for me,
            is that possible ?


            --
            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
          • Roy Fulbright
            Date: Sat, 8 Dec 2012 00:58:09 -0500 From: songpingemail@gmail.com To: vim_use@googlegroups.com CC: rfulbrig@hotmail.com Subject: Re: vimdiff: how to calculate
            Message 5 of 7 , Dec 7, 2012
            • 0 Attachment

              Date: Sat, 8 Dec 2012 00:58:09 -0500
              From: songpingemail@...
              To: vim_use@...
              CC: rfulbrig@...
              Subject: Re: vimdiff: how to calculate "delta" for digits in different lines?

              On 12/8/2012 12:20 AM, Roy Fulbright wrote:
              > > Date: Fri, 7 Dec 2012
                    23:50:17 -0500

                    > > From: songpingemail@...

                    > > To: vim_use@...

                    > > Subject: vimdiff: how to ignore all same lines and show
                    ONLY diff lines?

                    > >

                    > > exports:

                    > > by default vimdiff will not only show the diff lines,
                    but also show a

                    > > couple of same lines to give you a sense of context.

                    > > how to suppress all same lines and display only those
                    diff lines?

                    > >

                    > > regards

                    > > ping

                    > >

                    > > --

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

                    >

                    > Add the following line to .vimrc:

                    > set diffopt=filler,context:0

                    >

                    > --

                    > 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



              thanks Roy (and Tony), that really works!

              now I still feel that is a big weak comparing to what I wanted achieve:

              say I have these 2 captures from the devices:

                Multicast routing enabled               Multicast routing enabled                                                   
                Use Framed Routes = disabled                    Use Framed Routes = disabled                                                

                In Received Packets 10, Bytes 1000              In Received Packets 15, Bytes 150                                           
                  Unicast Packets 10, Bytes 1000                  Unicast Packets 15, Bytes 150                                             
                  Multicast Packets 0, Bytes 0                    Multicast Packets 1, Bytes 54                                             
                In Policed Packets 0, Bytes 0                   In Policed Packets 0, Bytes 0                                               
                In Error Packets 0                              In Error Packets 0                                                          
                In Invalid Source Address Packets 0             In Invalid Source Address Packets 0                                         
                In Discarded Packets 0                          In Discarded Packets 0                                                      
                Out Forwarded Packets 100, Bytes 10000          Out Forwarded Packets 150, Bytes 15000                                      
                  Unicast Packets 100, Bytes 10000                Unicast Packets 150, Bytes 15000                                          
                  Multicast Routed Packets 0, Bytes 0             Multicast Routed Packets 0, Bytes 0                                       
                Out Scheduler Dropped Packets 0, Bytes 0        Out Scheduler Dropped Packets 0, Bytes 0                                    
                Out Policed Packets 0, Bytes 0                  Out Policed Packets 0, Bytes 0                                              
                Out Discarded Packets 0                         Out Discarded Packets 0                                                     



              with above solution now I can focus on lines with an increased counter(s).
              But quite often I need to manually calculate the "delta" amount of those counters.
              so instead of just mark the diff lines, ideally if I can have the 2nd diff window displaying only the delta of those counters whenever there is any difference

              29   In Received Packets 10, Bytes 1000          29   In Received Packets 5, Bytes 500         
              30     Unicast Packets 10, Bytes 1000                   30     Unicast Packets 5, Bytes 500           
              31     Multicast Packets 0, Bytes 0                     31     Multicast Packets 1, Bytes 54          
              32 +--  4 lines: In Policed Packets 0, Bytes 0          32 +--  4 lines: In Policed Packets 0, Bytes 0
              36   Out Forwarded Packets 100, Bytes 10000             36   Out Forwarded Packets 50, Bytes 5000     
              37     Unicast Packets 100, Bytes 10000                 37     Unicast Packets 50, Bytes 5000         

              I don't find existing functions/scripts (say script 3745 or 3075) can do that for me,
              is that possible
               
               
              The easiest way I found to calculate and display the delta of lines that differ is to write a short Perl program:
               
              #!/usr/bin/perl
              use strict;
              use warnings;
              my $file1 = "diff1.txt";
              my $file2 = "diff2.txt";
              open(my $fh1,'<', $file1) or die "Error opening $file1: $!\n";
              open(my $fh2,'<', $file2) or die "Error opening $file2: $!\n";
              while ( !eof($fh1) && !eof($fh2) ) {
                  my $t1 = <$fh1>;
                  my $t2 = <$fh2>;
                  chomp $t1;
                  chomp $t2;
                  if ($t1 ne $t2) {
                      my ($p1,$b1) = $t1 =~ /(\d+).*?(\d+)/;
                      my ($p2,$b2) = $t2 =~ /(\d+).*?(\d+)/;
                      my $pdelta = $p2 - $p1;
                      my $bdelta = $b2 - $b1;
                      print pack("A42",$t1), pack("A42",$t2), "$pdelta  $bdelta\n";
                  }
              }


              --
              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
            • ping
              ... Many thanks Roy! this remind me that external tool can be used/created here but still called from inside vim if one (I) is not capable of making complex
              Message 6 of 7 , Dec 8, 2012
              • 0 Attachment
                On 12/8/2012 2:01 AM, Roy Fulbright wrote:
                > The easiest way I found to calculate and display the delta of lines
                > that differ is to write a short Perl program:
                >
                > #!/usr/bin/perl
                > use strict;
                > use warnings;
                > my $file1 = "diff1.txt";
                > my $file2 = "diff2.txt";
                > open(my $fh1,'<', $file1) or die "Error opening $file1: $!\n";
                > open(my $fh2,'<', $file2) or die "Error opening $file2: $!\n";
                > while ( !eof($fh1) && !eof($fh2) ) {
                > my $t1 = <$fh1>;
                > my $t2 = <$fh2>;
                > chomp $t1;
                > chomp $t2;
                > if ($t1 ne $t2) {
                > my ($p1,$b1) = $t1 =~ /(\d+).*?(\d+)/;
                > my ($p2,$b2) = $t2 =~ /(\d+).*?(\d+)/;
                > my $pdelta = $p2 - $p1;
                > my $bdelta = $b2 - $b1;
                > print pack("A42",$t1), pack("A42",$t2), "$pdelta $bdelta\n";
                > }
                > }
                Many thanks Roy!
                this remind me that external tool can be used/created here but still
                called from inside vim if one (I) is not capable of making complex vim
                script...

                regards
                ping

                --
                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
              • Gary Johnson
                ... Using a Vim script is not always the best solution, even if you are a Vim expert. In this case, I think that an external script written some language such
                Message 7 of 7 , Dec 9, 2012
                • 0 Attachment
                  On 2012-12-08, ping wrote:
                  > On 12/8/2012 2:01 AM, Roy Fulbright wrote:
                  > >The easiest way I found to calculate and display the delta of lines
                  > >that differ is to write a short Perl program:

                  > Many thanks Roy!
                  > this remind me that external tool can be used/created here but still
                  > called from inside vim if one (I) is not capable of making complex
                  > vim script...

                  Using a Vim script is not always the best solution, even if you are
                  a Vim expert. In this case, I think that an external script written
                  some language such as Perl or awk that is designed for such tasks is
                  a better choice than a Vim script.

                  Regards,
                  Gary

                  --
                  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
                Your message has been successfully submitted and would be delivered to recipients shortly.