如何在Eclipse PDT中重新格式化多行注释?

mjs*_*mjs 10 php eclipse comments eclipse-pdt reformat

Eclipse PDT,Ctrl-Shift-F重新格式化代码.但是,它根本不会修改注释.有没有办法将不规则的多行注释重新格式化为每行80个字符(或其他)?

即转换

// We took a breezy excursion and 
// gathered Jonquils from the river slopes.  Sweet Marjoram grew 
// in luxuriant 
// profusion by the window that overlooked the Aztec city.
Run Code Online (Sandbox Code Playgroud)

// We took a breezy excursion and gathered Jonquils 
// from the river slopes.  Sweet Marjoram grew in 
// luxuriant profusion by the window that overlooked 
// the Aztec city.
Run Code Online (Sandbox Code Playgroud)

(我认为这也适用于常规Eclipse.)

更新原来EclipseJava模式下将重新格式化上面的行,但前提是它们是/**/ - 样式的注释.它会缩短//太长的行,但它不会连接太短的行.

Jes*_*erE 2

您可能需要配置 Java 格式化程序以包含注释。

首选项 -> Java -> 代码样式 -> 格式化程序 -> 编辑... -> 注释

确保“启用 XXX 评论格式”已启用。

  • 看起来这在 Java 模式下确实有效,但在 PDT 下却不起作用。然而,由于某种原因,它只会完全重新格式化 /* */ 或 /** */ 注释——它会使 // 太长的行变短,但不会使较短的行变长。 (2认同)