格式化后无法删除 Eclipse 中的块注释

Cannot remove block comment in Eclipse after formatting(格式化后无法删除 Eclipse 中的块注释)

本文介绍了格式化后无法删除 Eclipse 中的块注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Eclipse 的自动格式化程序会更改块注释,因此 Source > Remove Block Comment 不会完全删除块注释.Source > Add Block Comment 将时钟注释的开始和结束添加到代码行中,但是在运行 Formatter (Ctrl + Shift + F) 后,它会包装代码行并在每行的开头添加一个星号.当我尝试使用 Source > Remove Block Comment 删除块注释时,块注释的开头和结尾被删除,但每行开头的星号不会被删除.

Eclipse's automatic formatter changes block comments such that the Source > Remove Block Comment does not completely remove the block comment. Source > Add Block Comment adds the start and end of the clock comment to the lines of code, but after running the Formatter (Ctrl + Shift + F), it wraps the lines of code and adds an asterisk to the start of each line. When I try to remove the block comment with Source > Remove Block Comment, the start and end of the block comment is removed, but the asterisks at the beginning of each line is not removed.

如何防止 Eclipse 添加这些星号,或者在删除块注释的开头和结尾时删除星号?

How do I prevent Eclipse from adding these asterisks, or remove the asterisks when it removes the start and end of the block comment?

示例:

这样的代码:

    String abc="abc";
    String def="def";
    System.out.println(abc+def);
    System.exit(0);

添加块评论后变成这样:

Becomes like this after adding block comments:

/*  String abc="abc";
    String def="def";
    System.out.println(abc+def);
*/  System.exit(0);

应用格式后变成这样:

    /*
     * String abc="abc"; String def="def"; System.out.println(abc+def);
     */System.exit(0);

使用删除块评论功能后,结果如下:

Which ends up like this after using the Remove Block Comment function:

    * String abc="abc"; String def="def"; System.out.println(abc+def);
    System.exit(0);

推荐答案

这可能有点晚了,但我通过禁用块评论格式解决了这个问题.

This may be a little late in the game, but I fixed this by disabling block comment formatting.

Windows -> Preferences -> Java -> Code Style -> Formatter -> Edit -> Comments

然后取消选中启用块注释格式.

这篇关于格式化后无法删除 Eclipse 中的块注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:格式化后无法删除 Eclipse 中的块注释

基础教程推荐