Eclipse auto-formatter, disable auto line-wrapping of comment lines

不问归期 提交于 2019-12-03 14:38:58

问题


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


回答1:


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 on Edit...
  • 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.




回答2:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!