IDE中是否有任何工具可以自动修复注释格式?

时间:2010-03-08 17:18:54

标签: visual-studio eclipse ide netbeans comments

/* Suppose I have a multi-line comment with hard line-breaks
 * that are roughly uniform on the right side of the text,
 * and I want to add text to a line in order to make the
 * comment a bit more descriptive.
 */

现在,最不幸,我需要在其中一个顶部行添加文字。

/* Suppose I have a multi-line comment with hard line-breaks (here is some added text for happy fun time)
 * that are roughly uniform on the right side of the text,
 * and I want to add text to a line in order to make the
 * comment a bit more descriptive.
 */

需要 O(n)时间( n 是行数)来修复每一行,以便它们再次大致排列。电脑应该这样做,而不是我。

我们的IDE中是否有处理此问题的工具?他们叫什么?

2 个答案:

答案 0 :(得分:4)

emacs支持fill-paragraph命令,该命令通常映射到meta-q

fill-paragraph在第二段文字中的输出:

/* Suppose I have a multi-line comment with hard line-breaks (here is
 * some added text for happy fun time) that are roughly uniform on the
 * right side of the text, and I want to add text to a line in order
 * to make the comment a bit more descriptive.
 */

答案 1 :(得分:2)

Eclipse内置了这个(至少,我认为这是你想要的)。当您键入注释时,然后键入Ctrl + Shift + F,它将格式化您的所有代码,或者只是您突出显示的代码部分。

我现在只是对它进行了测试,它对我的​​所有评论都是一致的。