使用 Eclipse 编码时,如何关闭启动多行注释时出现的“*”注释?
而不是看到这个,
/**
* Here is a comment
* some more
*/
我能得到这个吗?
/**
Here is a comment
some more
*/
如果你想知道“/**”是因为我使用了 doxygen。
使用 Eclipse 编码时,如何关闭启动多行注释时出现的“*”注释?
而不是看到这个,
/**
* Here is a comment
* some more
*/
我能得到这个吗?
/**
Here is a comment
some more
*/
如果你想知道“/**”是因为我使用了 doxygen。
如该线程中所述,您只能通过转到
Preferences > Java > Code Style > Code Templates
例如,如果您将字段注释的模板修改为:
/**
*/
当您评论字段时,它将以这种方式出现(中间没有任何星号)。
但是,它确实违反了Java 注释格式到 jdk1.3的Sun 约定(更新:当前的 oracle 链接)(也可以在此处看到)......
但是,正如Amedee Van Gasse的评论中所指出的:
从 Javadoc 1.4 开始,前导星号是可选的。
一种更简单的方法(如果您只需要对代码的某些注释执行此操作,同时保持另一个具有标准样式)是,当多行注释出现如下时:
/**
*
*/
,您可以先删除一个前导星号,然后输入您的评论。
您将看到在每行新注释的开头没有其他前导星号出现。
/**
*/
/**
My first line of comment
My second line of comment
My third line of comment
*/
在 eclipse 4.2.1 中,我使用了 formatter off / on 功能,请确保不要将 formatter on 标记与注释标记放在同一行,否则星星的噩梦将会回来。
// @formatter:off
/*
Eclipse your * are messing up my comments big time and If I used you
more often I'd put a patch together to add back in the "Add Leading Star" option
*/
// @formatter:on
必须在 Eclipse 首选项中“打开”开/关功能:Java > Code Style > Formatter。单击“编辑”按钮,“关闭/打开标签”,选中“启用关闭/打开标签”。
从
如何为 Java 代码的某些部分关闭 Eclipse 代码格式化程序?
还。我将标签更改为 //off //on 以便于使用