Eclipse Code Formatter 
Allows using Eclipse's code formatter directly from IntelliJ. Solves the problem of maintaining a common code style in team environments where both IDEA and Eclipse are used.
Currently supports formatting of
- Java (also emulates Eclipse's imports optimizing)
Instructions
- Install the plugin
- Configure it
- Get Eclipse formatter settings file:
- Either, export formatter profiles to get a
*.xmlfile- Go to
Eclipse, Windows, Preferences, Java, Code Style, Formatter - Eclipse does not export default profiles, so you have to make your own via the
Newbutton - Export the profile via the
Export all...button- The result should look like this
- Go to
- Or, enable project specific formatter settings to get
org.eclipse.jdt.core.prefs- With your project open in Eclipse's workspace,
right-clickthe project and choose Properties - Go to
Java Code Style, Formatterand selectEnable project specific settings - Click
OKto save the settings - Go to the
.settingsdirectory inside your project's directory. There you will find theorg.eclipse.jdt.core.prefsfile which contains the Eclipse formatter settings- The result should look like this
- With your project open in Eclipse's workspace,
- Or, export a [Workspace Mechanic] (http://marketplace.eclipse.org/content/workspace-mechanic/) configuration to get a
*.epffile- The result should look like this
- Either, export formatter profiles to get a
- Open a project in IntelliJ
- Set path to the config file via
IntelliJ, Settings, Other Settings, Eclipse Code Formatter, Eclipse preference file - When using exported profiles (the xml file), select desired profile in the combobox
Java formatter profile - Check
Optimizing Importsconfiguration- Set import order
- Either, leave the default
- Or, set path to Eclipse configuration file:
- Go to
Eclipse, Windows, Preferences, Java, Code Style, Organize Imports- Either, click on
Export..., (example) - Or, enable project specific settings and use
org.eclipse.jdt.ui.prefsfile which should contain the lineorg.eclipse.jdt.ui.importorder=...
- Either, click on
- Go to
- Set the value of
Class count to use import withandName count to use static import withinSettings, Editor, Code Style, Java, Importsfor Idea 14 orSettings, Editor, Code Style, Importsfor older Idea. Eclipse uses 99 by default - For versions lower than 4.0 - make sure to disable IntelliJ's
Import Optimizingin the reformat dialog viaSettings, Editor, Show "Reformat Code" dialog. The plugin will take care of imports anyway - For versions higher than 4.0 - imports will be reordered together with normal IntelliJ's import optimizing
- Disable
Optimize imports on the fly
- Set import order
- Get Eclipse formatter settings file:
- Format code as usual, notice the green bubble notification about successful formatting
- notifications can be disabled at
Settings, Notifications
- notifications can be disabled at
- Use
Ctrl + Alt + Oas usual, it will use this plugin - Use
Ctrl + ~for quick switch between formatters or icon at the main toolbar - Give it 5 stars
- Make a donation
Possible problems with Java formatting
@formatter:offis not working
See: https://github.com/krasa/EclipseCodeFormatter/issues/64- Nothing was formatted or formatting failed
- Make sure you are using proper language level in
Main Menu, File, Project Structure
- Make sure you are using proper language level in
- Trailing spaces inside javadocs are stripped
- Set
Strip trailing spaces on savetoNone
- Set
- File is formatted differently
- The file is actually formatted fine, it just looks different in the editor, as the tab size and indendation are set differently in IntelliJ in
Settings, Editor, Code Style, Javathan in Eclipse. Using of either tab only or space only whitespace is recommended. - Or it is a bug
- The file is actually formatted fine, it just looks different in the editor, as the tab size and indendation are set differently in IntelliJ in
- Eclipse indendation is configured for 2 spaces, but a new line gets indented by 4 spaces when Enter is pressed.
- Change code style in IntelliJ. Not all things get formatted by this plugin when you type them.
- If nothing helps
- check old issues
- Create a new issue here
Troubleshooting
If it is mysteriously not working, go to Main Menu, Help, Edit Debug Settings and add:
krasa.formatter
Try to reformat something and create a new issue, including the log

YourKit supports open source projects with its full-featured Java Profiler.
YourKit, LLC is the creator of YourKit Java Profiler
and YourKit .NET Profiler,
innovative and intelligent tools for profiling Java and .NET applications.