Oliver Wehrens
Seasoned Technology Leader. Mentor. Dad.
Oliver Wehrens

Sorting your properties files in IntelliJ Idea

- 1 min

I do work with language property files pretty much every day (since I’m the GUI guy in the team). The files are updated on different branches copied up to the trunk and merged down to new branches, sometimes even updated by our product owner. We got a couple of times into not so funny merge conflicts since people did not sort the property files in the same way. To get around that we used an external tool to sort the files just before committing them.

Right, we can do better than this.

I wrote a small plugin for IntelliJ IDEA (and turns out my colleague too) for sorting these inside IDEA. I took the easy approach to sort them in the editor window. Simply open a properties file and choose Code - Sort Properties. It detects if this is a real properties file (e.g. all lines do have a # at the start or do follow the pattern key=value) and sorts them. If things go boom you always can undo ;-). You can get it from here. It’s just 7KB since I did not include the testng jars.