Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an Intellij and Eclipse compatible code style and code formatting configuration (for java code)?

Few weeks ago I tried Intellij and I found it really awesome. Now, at my project there are two programmers (including me) using Intellij and few other programmers who are going to keep using Eclipse. Since this project is already very large and it's going to grow a lot, we need to use compatible Code Style and Code Formatting between Intellij and Eclipse. We do not want to have problems when one user edits some file and reformats it before saving. With Eclipse "alone" we used to have some exported configuration, and before anybody starts to work, the first step is just to import this configuration. We already tried to use External Code Formatter, but it didn't work on Intellij 9.

So, I have a bunch of questions here:

  1. Is there any way to import eclipse formatting configuration on Intellij 9?
  2. Anybody could share their experience managing this kind of situation? Do you guys have any other suggestion to manage this situation?
like image 736
user141634 Avatar asked Apr 08 '10 23:04

user141634


People also ask

How do I add code style to IntelliJ?

Apply a predefined code stylePress Ctrl+Alt+S to open the IDE settings and select Editor | Code Style. To configure a scheme for new projects, go to File | New Projects Setup | Settings/Preferences for New Projects | Editor | Code Style. Select the language for which you want to configure the code style.

How do I run code formatter in IntelliJ?

Sometimes code formatting can get out of sync, but there's an easy fix in IntelliJ IDEA. You can use ⌘⌥L (macOS), or Ctrl+Alt+L (Windows/Linux) to reformat a selection of code according to your reformat settings.

What is IntelliJ code style?

Code style scheme settings are automatically applied every time IntelliJ IDEA generates, refactors, or reformats your code. The IDE comes with two pre-defined schemes: the Project scheme and the Default scheme. In the Project scheme, the settings that you configure apply only to your current project.


2 Answers

There is an updated plugin for IDEA, called Eclipse Code Formatter: http://plugins.intellij.net/plugin/?idea&id=6546

like image 127
Aliaksandr Autayeu Avatar answered Sep 20 '22 22:09

Aliaksandr Autayeu


I would recommend someone spends the time to configure their IntelliJ's code style to be the same as Eclipse. This will take a little time and effort but once it is done, you can export it just like in eclipse so that any other IDEA users can import it.

You could also search online to see if anyone has already done this and you can simply download the code style config and use it.

The only alternative I can think of would be to find a standardized code style template that is available for both eclipse and IntelliJ, like the Recommended Sun Java Code Style.

like image 36
Jesse Webb Avatar answered Sep 18 '22 22:09

Jesse Webb