I love eclipse auto formatting, but there's one feature that's driving me raging mad:
Since I use wrap-lines in my auto-formmatter, code like this:
private static Location _location = null; // this is a comment
turns into horrible, horrible code like this:
private static Location _location = null; // this
// is
// a
// comment
this is not only painful to watch, but not at all convenient to change back...
Is there any way to remove line-wrapping for comments, or at least fix so it doesn't look like an absolute mess?
Thanks
I think that the thing you are specifically asking about you can achieve by editing your formatter:
Window
->Preferences
->Java
->Code Style
->Formatter
. There edit you click onEdit...
- If you are using the default Eclipse formatter you will need to edit the profile name (you cna not edit built in profile).
- Go to comments
- Deselect line comment formatting.
That way no formatting of comments of the type //
will be done.
This annoys me also. To fix the wrapped comments you can use the keyboard shortcut CTL+ALT+J to join the comments onto one line. The comment-indicator characters (// or *) will still be there but at least it will save you some steps. Then you can just run a find and replace for the comment-indicators.
来源:https://stackoverflow.com/questions/9645322/eclipse-auto-formatter-disable-auto-line-wrapping-of-comment-lines