Community
    • Login

    Compare plugin is back!

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    24 Posts 17 Posters 509.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • guy038G
      guy038
      last edited by guy038

      Hello, @john-powers,

      I think that I succeeded to find a way to easily see the differences between your two files, that I downloaded, yesterday …, if you don’t mind that sections and lines, inside sections, are sorted out :-D

      Let me explain the general idea :

      Assuming the original text :

      [Section XYZ]
      lllll
      wwwww
      aaaaa
      fffff
      
      [Section ABC]
      lllll
      bbbbb
      wwwww
      

      I thought, with the help of some regular expressions, to transform this text, in such a way :

      [Section XYZ]lllll
      [Section XYZ]wwwww
      [Section XYZ]aaaaa
      [Section XYZ]fffff
      [Section ABC]lllll
      [Section ABC]bbbbb
      [Section ABC]wwwww
      

      Then, using the usual lexicographically sort, it would ends to :

      [Section ABC]bbbbb
      [Section ABC]lllll
      [Section ABC]wwwww
      [Section XYZ]aaaaa
      [Section XYZ]fffff
      [Section XYZ]lllll
      [Section XYZ]wwwww
      

      Once this way done, for your two files, the compare results are just fine to study !!


      As I supposed you’re eager to see if my method could be of interest for you, I will, simply, give you the different regex S/R to run, without any explanation, for the first time. Afterwards, if you need it, I’ll able to develop these regexes !

      I, simply, renamed your files, as File_1.txt and File_2.txt. All the process, below, has to be executed for your TWO files ! So :

      • Open the File_1.txt file in Notepad++

      • Move back at to its very begining, if necessary ( Ctrl + Home)

      • Open the Replace dialog ( Ctrl + H )

      • Untick any option

      • Select the Regular expression search mode ( IMPORTANT )

      Remarks :

      • Throughout all the process, the cursor position will never change ( at beginning of line 1 )

      • It would better to copy/paste the different regexes from your browser to the Replace dialog zones, instead of typing in, manually !


      FIRSTLY, we delete extra blank lines, but an unique line spacing ( for the good execution of the following regexes ! ) :

      • Type (\R\R)\R+, in the Find what: zone

      • Type \1, in the Replace with: zone

      • Click on the Replace All button, exclusively

      => In your case, with your files, you should get the Replace All:O occurrences were replaced message. However, it’s best to run this S/R, in all cases, in order to clean up the contents !


      I noticed, that, sometimes, you have sections, with no element at all ( as, for instance, [death], [EMPTY CONTEXT],… ). I preferred to add the single element NONE, right under its section’s name. So :

      SECONDLY, we add the dummy single element NONE, to each orphan section :

      • Type (?-s)^\[.+?\]\R(?=\R), in the Find what: zone

      • Type $0NONE\r\n, in the Replace with: zone

      • Click on the Replace All button, exclusively

      In your case, you should obtain 4 replacements !


      Now, for the good execution of the fourth and last regex S/R, we’re going to swap, the name and contents of each section. That is to say that, from the text :

      [section AAA]
      11111
      22222
      33333
      
      [section BBB]
      

      we want to obtain :

      11111
      22222
      33333
      [section AAA]
      
      [section BBB]
      

      =>

      THIRDLY, we move each section’s name, downwards, AFTER its block of elements :

      • Type (?-s)^(\[.+\R)(?s)(.+?\R)(?=\R?\[|\Z), in the Find what: zone

      • Type \2\1, in the Replace with: zone

      • Click on the Replace All button, exclusively


      Finally, we add, in front of any element of any section, its section’s name and we delete any individual section’s name, located at the end of each block. That is to say that, from the text :

      11111
      22222
      33333
      [section AAA]
      

      we want to obtain :

      [section AAA]11111
      [section AAA]22222
      [section AAA]33333
      

      =>

      FOURTHLY, we add the appropriate section’s name, at beginning of each element and we delete the individual section’s name lines :

      • Type (?-s)^[^\r\n[].+(?=(?s:.+?)\R(\[.+?\]))|^\[.+?\]\R+, in the Find what: zone

      • Type (?1\1$0), in the Replace with: zone

      • Click on the Replace All button, exclusively

      • Save this version, as File_3.txt

      • Execute the menu choice Edit > Line Operations > Sort Lines Lexicographically Ascending

      • Save this sorted version, as File_5.txt


      Then, follow the same steps as above, with your second file File_2.txt

      • After the four regex S/R, save that version, as File_4.txt

      • Execute the menu choice Edit > Line Operations > Sort Lines Lexicographically Ascending

      • Save this sorted version, as File_6.txt


      Finally, run the Plugins > Compare > Compare command, on File_5.txt and File_6.txt files. Do you like it ?!

      Just try to compare File_3.txt and File_4.txt files, BEFORE sorting, it’s quite tedious, isn’t it ? :-D And, even if you uncheck the option Plugins > Compare > Detect Moves, it’s still be complicated to analyse, isn’t it ?

      Anyway, I hope, that I correctly interpreted your needs !

      Best Regards,

      guy038

      PS : Of course, I’m using the excellent Compare plugin, last version v2.0.0, of Pavel Nedev ( alias @pnedev )

      I forgot to give some statistics about your two files :

      Concerning the File_5.txt file :

      • 43 sections, containing 2416 elements

      • 4 orphan sections, with 4 NONE elements

      => A total of 47 sections, for 2420 elements

      • 13 minus sign red bookmarks, after the compare process

      Concerning the File_6.txt file :

      • 42 sections, containing 2486 elements

      • 4 orphan sections, with 4 NONE elements

      => A total of 46 sections, for 2490 elements

      • 83 plus sign green bookmarks, after the compare process

      And the differences are :

      • The section [BASE_CameraMovement] absent in File_6.txt

      • 70 elements, added in File_6.txt ( 2490 - 2420 ), which is, exactly, the difference between the bookmarked lines ( 83 - 13 ) !

      1 Reply Last reply Reply Quote 0
      • TekBearT
        TekBear @John Powers
        last edited by

        @John-Powers have you considered using a separate tool? When I need to merge to “ini” type files I use the file compare feature in “total commander”. I can edit side by side in file compare feature, see the differences and manually copy and paste differences . You can download total commander and try it.

        1 Reply Last reply Reply Quote 0
        • Pawan KumarP
          Pawan Kumar
          last edited by

          I downloaded https://github.com/pnedev/compare-plugin/releases/tag/v2.0.0. and used.
          After installing this plug in my notepad++ became unstable and starting behaving weirdly. I have uninstalled the plug-in as well as notepad++. Will re-install notepad++ alone and check.

          1 Reply Last reply Reply Quote 0
          • dinkumoilD
            dinkumoil
            last edited by

            @Pawan-Kumar

            I never noticed that the Compare plugin caused Notepad++ to be unstable. But there are some other plugins doing so, e.g. MenuSearch and LocationNavigate. Especially MenuSearch is weird because wether it causes problems depends on the presence and/or absence of other plugins. At my site it works fine if NppFTP is installed as well.

            You should try to install one plugin after another and perform tests after every installation until you find a plugin which causes problems. Then uninstall all other plugins and test the suspicious one alone. If it works fine start adding other plugins until you are facing problems again. Then remove all plugins except the first and the second suspicious one and repeat the sequence.

            This way you will find combinations of plugins which effect each other in ways that make Notepad++ become unstable.

            1 Reply Last reply Reply Quote 3
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors