是否有办法阻止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
转到“窗口”菜单->首选项从左侧列表中选择所需的编辑器(例如Java)。然后应该有一个名为“代码样式”的小节,并且在该“格式化程序”下。
还有另一种解决方案,可以用来禁止特定块注释的格式。在块注释的开头使用/ *-(注意连字符),并设置格式如果您格式化文件的其余部分,则不会受到影响。
Window-> Preferences-> Java-> Code Style-> Formatter。创建新的格式化程序。单击编辑,然后选择选项卡未选中注释启用行注释格式和启用块注释格式
您可以使用<pre></pre>
包装,此块将不会格式化。