I love the "Reformat code..." (Ctrl+Alt+L) function of IntelliJ IDEA.
Now I have a lot of XML files to look through. What I am doing now is, I open a xml file, select all, copy and paste into a xml file opened by IntelliJ IDEA, then use the "Reformat code..." to beautify the xml file, after that, I copy the formatted xml file back to the original xml file.
It is time consuming and not fun at all.
It would be great if the "Reformat code..." function can be taken out of IntelliJ IDEA into a command line tool to beautify all my xml files (any other files like java, ...) all at once.
So I begin to study the source code of ideaIC-99.18. And find the CodeFormatterFacade class and package com.intellij.formatting. But it still looks like, to me, will need a lot of work to do.
Does anyone ever think of it of have done it before? Any suggestions are appreciated. Thanks a lot!
The IntelliJ IDEA formatter is pretty tightly coupled to the rest of the code. The easiest way to have it run standalone is to write a plugin implementing the ApplicationStarter interface, which allows to create command line-based tools based on IntelliJ IDEA. The big downside of this approach is that running the tool will still initialize most of IntelliJ IDEA's internals, so it will not be very fast.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With