Reformat code doesn't join lines

Hi,
I'm switching from Eclipse to IntelliJ (8.1.3) but I have currently problem with formatter in IntelliJ.
In Eclipse when I setup some rules and line length, the formatter will join two lines that obiously shouldn't be seperated:
int a = 2 + 3
    + 3 + 1;

Should become:
int a = 2 + 3 + 3 + 1;


But IntelliJ doesn't do that, I look almost everywhere, but I must be blind, because I don't see an option for this. It seams that IntelliJ only changes intendation, breaks lines that are too long, but doesn't join lines that can be longer.

Is there a way to achieve this in IntelliJ?

0
9 comments
Avatar
Permanently deleted user

In Eclipse when I setup some rules and line length, the formatter will join two lines that obiously shouldn't be seperated:


And that's one reason why I hate using Eclipse.

0
Avatar
Permanently deleted user

I don't think it is possible to change the behaviour of the code formatter to match the eclipse formatter for this particular feature.
I actually prefer the way IDEA handles the issue of split lines but that is just personal style  I guess.

However, there is a plugin called "External Code Formatter", that seems to be focussed on integrating the Eclipse formatter. From the plugin website:

Allows using external code formatters, especially Eclipse's code formatter, as well as any command line code formatting tools, from within IntelliJ IDEA.
Solves the problem of maintaining a common code style in team environments where both IDEA and Eclipse are used.

(http://plugins.intellij.net/plugin/?id=1605)

I haven't used this plugin so I don't know anything about it or how well it works. It does seem to be activly maintained though.
There are other plugins that support external code formatters - just search for "formatter" in the "available plugins" list (Settings -> Plugins -> Available-Tab).


Christian

0
Avatar
Permanently deleted user

See Settings -> Project Settings -> Code Style -> Alignment and Braces -> Keep When Reformatting -> Line Breaks
(Similar option exists also in the HTML and CSS subsections.)

Krzysztof Krason wrote:

Hi,
I'm switching from Eclipse to IntelliJ (8.1.3) but I have currently problem with formatter in IntelliJ.
In Eclipse when I setup some rules and line length, the formatter will join two lines that obiously shouldn't be seperated:
int a = 2 + 3
    + 3 + 1;

Should become:
int a = 2 + 3 + 3 + 1;


But IntelliJ doesn't do that, I look almost everywhere, but I must be blind, because I don't see an option for this. It seams that IntelliJ only changes intendation, breaks lines that are too long, but doesn't join lines that can be longer.

Is there a way to achieve this in IntelliJ?

---
Original message URL: http://www.jetbrains.net/devnet/message/5252038#5252038

0

Same hatred here.

I'm using IntelliJ, but some team members use Eclipse.

I spend quite some time to make my code easier to read, just to find it later "formatted nicely" (meaning no longer readable) by a colegue using the incredibly broken default formatting of Eclipse.

0
Avatar
Permanently deleted user

... incredibly broken default formatting of Eclipse.


I never got to manage to change Eclipse' behaviour. It either wrapped it
automatically or put everything in one line. There seems not to be an option
to keep the line breaks as they are. Fail.

0
Avatar
Permanently deleted user

Oh thanks for that tip by the way! That helps out quite a lot because I have often wondered how to get around that problem as well because everyone in my team uses Eclipse.

0
Avatar
Permanently deleted user

Thank you for the tip, I hope it really works. I'll check that when I'm back at work.

0
Avatar
Permanently deleted user

Whatever works for you

I just wanted to say why I need this functionality.
We are taking over a subproject from other team and in this project they were using line width of 80 chars (which I really don't understand, I like to use the full screen for reading) and in our project we use 120 chars, not tu mention that they were "pretty" formatting throws clauses which our checkstyle doesn't like.
Reading a call to a method that is in the middle of passing parameters broken into two lines is really really annoying when you see it for the 10-th time.

But as it was mentioned in this thread IntelliJ has a checkbox for that

0
Avatar
Permanently deleted user

You could configure Eclipse according to your needs and let it run over your
code. Then you can use IDEA, let it run over your code and commit it.

0

Please sign in to leave a comment.