Sorting your properties files in IntelliJ Idea

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

6 Responses to “Sorting your properties files in IntelliJ Idea”

  1. strug says:

    hi olli.

    why you won’t make it available over the idea plugin manager? just create a jetbrains account (http://account.jetbrains.com/) and there you go. easy for you. easier for us.
    thanks

  2. Oliver says:

    After some more testing on windows and putting the source up on google or so I will do that.

  3. Oliver says:

    The code is now available from googlecode.com (or within IntelliJ). Check Downloads for more information.

  4. Toby says:

    Great plugin, can you explain how it handles comments? It seems to delete them unless the comment looks like a commented property file? ta

  5. Oliver says:

    Yes, at the moment it deletes all comments since it does not keep track of which comment was placed right above which property.

    What do you think would be a useful behavior?

    Update: I released version 0.3 where comments will not deleted anymore. They now always stick to the next line containing a property. See also http://maxheapsize.com/2009/05/05/intellij-idea-plugin-property-sorter-updated/.

  6. Frederik Skytte says:

    A feature I am missing is to sort only parts of a file. In our larger property files we have properties in different groups. It would be great to be able to select a group and sort only that group, for instance by right-clicking and saying Sort Properties… (Or Refactor->Sort Properties). Great job by the way!

Leave a Reply

Additional comments powered by BackType