停止Eclipse处理我的评论

问题描述 投票:23回答:5

是否有办法阻止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
eclipse comments code-formatting
5个回答
15
投票

转到“窗口”菜单->首选项从左侧列表中选择所需的编辑器(例如Java)。然后应该有一个名为“代码样式”的小节,并且在该“格式化程序”下。


70
投票

还有另一种解决方案,可以用来禁止特定块注释的格式。在块注释的开头使用/ *-(注意连字符),并设置格式如果您格式化文件的其余部分,则不会受到影响。


13
投票
  1. 转到首选项-> Java->代码样式->格式化程序

1
投票

Window-> Preferences-> Java-> Code Style-> Formatter。创建新的格式化程序。单击编辑,然后选择选项卡未选中注释启用行注释格式和启用块注释格式


0
投票

您可以使用<pre></pre>包装,此块将不会格式化。

© www.soinside.com 2019 - 2024. All rights reserved.