Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BeyondCompare for .properties

I am using BeyondCompare to compare files and am very happy with it. However I'd like to be comparing and cross-editing two .properties files as well. The specific is obvious - I do not care about the order of name/value pairs but I care about duplications etc. Does anyone knows (or also needs) such an application?

like image 444
Dima Avatar asked Dec 30 '25 18:12

Dima


2 Answers

There is a trick to sort the properties by key name when saving.

Or sort both files before comparing them.

like image 121
Thomas Mueller Avatar answered Jan 02 '26 07:01

Thomas Mueller


I found a way that works pretty good for me.

As far as I can tell, the only problem with this approach is that when you save any change made using Beyond Compare, the properties file get all messed up; so you need to select the File format "<default>" before save or make the changes outside of Beyond Compare.

Based on the message #2 and the link it contains. I'm using BC v3.3.13

The trick is to create a special file format:

  1. Go to the menu Tools / File Formats...
    • create (click on lower left new button) or ...
    • modify one (selecting it)
  2. Set a proper name for it: Properties
  3. In the General tab set the mask: *.properties
  4. In the Conversion tab set Sorting
  5. In the Gramar tab
    • key=value
      1. Click New button
      2. Set a proper name: Equal sign to the end
      3. Click in the radio button named Delimited
      4. Put an equal sign (=) in the Text from: field
      5. Set the checkbox named Stop at end of line
    • comments
      1. Click New button
      2. Set a proper name: Comments
      3. Click in the radio button named Delimited
      4. Put a sharp sign (#) in the Text from: field
      5. Set the checkbox named Stop at end of line
  6. Click on the Save button or press Alt-S
  7. Close the shown dialog
  8. Press the reload toolbar icon, or select manually the new file format

Comparison example

  1. You can tell Beyond compare the text after the equal sign and after the sharp sign are unimportant:
    1. Click in the rules tool bar icon (the guy with a hat) (is shown inside a blue oval in the previous image)
    2. Go to the Importance tab
    3. Remove the check in both grammar elements:

enter image description here

4. Press the `Ok` button
  • Note Beyond Compare shows the file format in the two red ovals I added to the first image
  • Note Beyond Compare tells you the files are NOT shown as they are in the file system, but they are converted (sorted) if you see the text to the right of the ovals shown.

Hope it helps someone.

like image 22
elysch Avatar answered Jan 02 '26 08:01

elysch