'Is there a way to unwrap an already wrapped code in Intellij / Eclipse?

I have code that was formatted based on a wrap of 120 chars. I changed the setting to wrap it at 200 chars in IntelliJ CE. Running a reformat doesn't re-wrap the code as per 200 char limit. I am having to manually move the split lines up to a single line.

Example of existing code :

final MyOwnFactoryClass myOwnFactoryClass = new 
MyOwnFactoryClass(myStringVar1 , myStringVar2, 
myStringVar3);

How I want it to look

final MyOwnFactoryClass myOwnFactoryClass = new MyOwnFactoryClass(myStringVar1 , myStringVar2, myStringVar3);

Is there an easier way of doing this either in IntelliJ or Eclipse?

For those wondering why I need this, I have new code that I need to read through and it is extremely tough reading and interpreting in the 1st format. And no the company has no code standards so I won't be violating anything.

Would changes to plugins or settings be of use?



Solution 1:[1]

I found a way just by experimenting :) . Intellij --> File --> Settings (Preferences for MacOS) --> Code Style --> Java --> Wrapping and Braces --> check all the align when multiline option in for all the blocks you want like for(), if(), while() etc. --> Apply --> run code format. and it should do the needful! :)

Solution 2:[2]

Aside from working with the automatic formatting, you can use the "Join Lines" action.
With the cursor on the first part of the line, select the action, either by name (using Cmd-Shift-A or double-shift) or with the keyboard shortcut Ctrl-Shift-J.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 LeoNeo
Solution 2 Joshua Goldberg