Compare plugin is back!
-
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, containing2416
elements -
4
orphan sections, with4
NONE elements
=> A total of
47
sections, for2420
elements13
minus sign red bookmarks, after the compare process
Concerning the File_
6
.txt file :-
42
sections, containing2486
elements -
4
orphan sections, with4
NONE elements
=> A total of
46
sections, for2490
elements83
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
) !
-
-
@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.
-
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. -
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.