阻止 Eclipse 破坏我的评论
有没有办法阻止 Eclipse 破坏我的源文件中的注释?
我的主要问题是阻止它自动换行。我已经设法将 Eclipse 配置为不自动换行任何代码,但它似乎仍然对注释执行此操作。
我输入的代码如下:
public int myVariable = 100; // this variable is a very interesting variable and it does lots of stuff
最终结果如下:
public int myVariable = 100; // this variable
// is a very
// interesting
// variable and
// it does lots
// of stuff
Is there a way to stop eclipse from mangling the comments in my source files?
My main issue is stopping it from word wrapping them. I've managed to configure eclipse to not word wrap any code but it still seems to do it to comments.
Code that I enter like this:
public int myVariable = 100; // this variable is a very interesting variable and it does lots of stuff
End up like this:
public int myVariable = 100; // this variable
// is a very
// interesting
// variable and
// it does lots
// of stuff
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以使用另一种解决方案来抑制特定块注释的格式。在块注释的开头使用 /*- (注意连字符),并格式化
如果您格式化文件的其余部分,则不会受到影响。
来源:http://www.oracle.com/technetwork /java/javase/documentation/codeconventions-141999.html#680
There is another solution that you can use to suppress the formatting of specific block comments. Use /*- (note the hyphen) at the beginning of the block comment, and the formatting
won't be affected if you format the rest of the file.
Source: http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141999.html#680
转到“窗口”菜单->偏好
从左侧列表中选择您感兴趣的编辑器。(例如Java)
那么应该有一个名为“代码样式”的小节,在“格式化程序”下。
然后您需要创建一个新的格式化程序配置文件。 (内置配置文件无法编辑)
配置文件配置的最后一个选项卡是注释格式选项
Go to the "Window" menu -> preferences
choose the editor you're interested in from the list on the left.(e.g. Java)
then there should be a subsection called "Code Style", and under that "Formatter".
Then you'll need to create a new formatter profile. (The built-in profile can't be edited)
On the last tab of the profile configuration is options for comment formatting
窗口->首选项->Java->代码样式->格式化程序。创建新的格式化程序。单击“编辑”,然后选择“注释”选项卡,取消选中“启用行注释格式”和“启用块注释格式”
Window->Preferences->Java->Code Style->Formatter. Create new formatter. Click on edit and then pick tab Comments unchecked Enable Line comment formatting and Enable block comment formatting
您可以使用
You can use
<pre></pre>
wrapped, this block will not format.