Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

HTML

Redirect
locationhttps://www.jetbrains.com/help/idea/code-style.html
HTML
<table width="100%">
<tr>
<td width="33%" align="left"><a href="http://confluence.jetbrains.com/display/IntelliJIDEA/Configure+Keymap">Previous</a></td>
<td width="33%" align="center"><a href="http://confluence.jetbrains.com/display/IntelliJIDEA/Working+in+Eclipse+Compatibility+Mode">Top</a></td>
<td width="33%" align="right"><a href="http://confluence.jetbrains.com/display/IntelliJIDEA/FAQ+on+Migrating+to+IntelliJ+IDEA">Next</a></td>
</table>
Developers who have used Eclipse for years may have built some strong expectations as to how an IDE has to behave and especially format code. In particular, you may be used to have having the IDE to save files automatically or to have tabs used instead of spaces or extra blank lines removed before a closing bracket.

...

Although through different user interfaces, Eclipse and IntelliJ IDEA offer nearly the same set of coding styles for you to configure. Configuration takes place from the

File →  Settings
span
classshortcut
Wiki Markup
{span:class=shortcut}File&nbsp;→&nbsp; Settings{span}
dialog box after selecting the Code Style node. You have styles grouped in various categories: General, Java, Groovy, HTML and XML.


 
Of particular relevance are the code style settings available for the Java language. Settings are grouped in different categories in Eclipse and IntelliJ IDEA. However as the next two screenshots show, categories address nearly the same set of parameters.

...

Both Eclipse and IntelliJ IDEA let you save all settings to a file. A settings file can then be imported later into another instance of the IDE. Note, though, that Eclipse has a direct Export button to export code styles. In IntelliJ IDEA, instead, you export and import all IDE settings, including code style schemes. You select

File →  Export Settings
span
classshortcut
Wiki Markup
{span:class=shortcut}File →&nbsp; Export Settings{span}
and select Code style schemes.

...

To import a previously saved settings file you select

File →  Import Settings
span
classshortcut
Wiki Markup
{span:class=shortcut}File →&nbsp; Import Settings{span}
.
IntelliJ IDEA allows to export and import IDE settings so that all users on a team can share the same settings, but this doesn't solve the problem of teaching IntelliJ IDEA to apply the settings in use in Eclipse.

...

  1. A developer on the team takes the burden of configuring his own instance of IntelliJ IDEA based on whatever collection of settings the team agrees on--including the common settings of Eclipse.
  2. You can install the following IntelliJ IDEA plug-in: http://plugins.jetbrains.com/plugin/?id=6546. The plug-in lets you use the Eclipse's code formatter directly from IntelliJ. In doing so, it solves two problems at the same time. First, it lets developers to work in IntelliJ IDEA with the same code style they were used to in Eclipse. Second, it helps maintaining a common coding style in collaborative environments where both IntelliJ IDEA and Eclipse are used.

...

Any other approach would anyway require that all relevant settings are manually entered and kept synced in both IDEs. It is then up to each team to decide about which code style settings are relevant to keep synced. 

HTML

<table width="100%">
<tr>
<td width="33%" align="left"><a href="http://confluence.jetbrains.com/display/IntelliJIDEA/Configure+Keymap">Previous</a></td>
<td width="33%" align="center"><a href="http://confluence.jetbrains.com/display/IntelliJIDEA/Working+in+Eclipse+Compatibility+Mode">Top</a></td>
<td width="33%" align="right"><a href="http://confluence.jetbrains.com/display/IntelliJIDEA/FAQ+on+Migrating+to+IntelliJ+IDEA">Next</a></td></table>