Reputation: 3030
While editing java code in eclipse, may be I pressed some key combo, or something else, but strings, code and comments in my entire file is now split into multiple lines. The newline is inserted at every object property/method.
Ex.:
object.prop1.method1()
has become:
object
.prop1
.method1()
What can I do to revert back???
Here is one small screenshot:
Thanx in advance...
Upvotes: 0
Views: 2055
Reputation: 3030
Thnx all for the suggestions....it worked by using code formatter and changing a few options
Thanx again...
Upvotes: 0
Reputation: 3304
If you press Ctrl+Shift+F your code gets formatted. (This must be what you pressed)
The formatter follows certain rules. You can find those rules if you go in Eclipse:
Window->Preferences->Java->Code Style->Formatter
There you must edit the current profile so that you can have more characters per line. This option is in tab
Line Wrapping -> Maximum line width
If you set this value large enough and press again Ctrl+Shift+F everything is going to be restored.
Upvotes: 1
Reputation: 7863
You might have hit the auto formatter with Ctrl + Shift + F. Although the formatting seems strange and would definetly not be the default. Try hitting it again and see what happens.
You can configure the formatter in the preferences under Java
=>Code Style
=>Formatter
Upvotes: 4
Reputation: 30865
Ctrl+ Shfit + F - the short cut for format.
If have saved and ctrl + z do not work than only a new roll out from repository. If you do not have any then you can change change your format settings and perform operation one more time, but this time on your rules .
To set the format go to:
Options > Preferences > Java > Code Style > Formatter
Upvotes: 3