使Eclipse的Java代码格式化器忽略块注释

86

有没有办法让Eclipse内置的Java代码格式化程序忽略注释?每次运行时,它会将这个变成:

    /*
     * PSEUDOCODE
     * Read in user's string/paragraph
     * 
     * Three cases are possible
     * Case 1: foobar
     *         do case 1 things
     * Case 2: fred hacker
     *         do case 2 things
     * Case 3: cowboyneal
     *         do case 3 things
     *         
     * In all cases, do some other thing
     */

转换为这个:

    /*
     * PSEUDOCODE Read in user's string/paragraph
     * 
     * Three cases are possible Case 1: foobar do case 1 things Case 2: fred
     * hacker do case 2 things Case 3: cowboyneal do case 3 things
     * 
     * In all cases, do some other thing
     */

我已经尝试过在Windows > Preferences > Java > Code Style > Formatter中进行设置,但找不到保持注释格式的选项。我正在使用Eclipse 3.4.0。


在格式化程序配置中就在那里,我不知道你怎么会错过它。编辑个人资料,有一个带有8个选项卡的对话框,最后一个选项卡是用于评论格式化的。 - skaffman
我确实看到了评论选项卡,但无论我使用哪种复选框组合,都会出现格式问题。 - Pops
我在Eclipse中使用Scala时遇到了同样的问题,但下面的解决方案都是针对Java的,因为Scala代码格式化选项卡有不同的选项。有没有办法关闭Scala的注释重新格式化? - Glenn Strycker
11个回答

0
你可以在Windows - 首选项 - Java - 代码样式 - 格式化器中进行更改,然后单击编辑按钮,找到评论,选择“永不连接行”。
然后,就应该没问题了。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接