代码之家  ›  专栏  ›  技术社区  ›  mjs

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

  •  10
  • mjs  · 技术社区  · 16 年前

    Eclipse PDT , Ctrl-Shift-F 重新设置代码格式。但是,它根本不修改注释。有没有什么方法可以将参差不齐的多行注释重新格式化为每行80个字符?

    i、 e.转换

    // 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.
    

    // 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.
    

    更新 Eclipse 在里面 Java mode将重新格式化上面的行,但前提是它们是/**/-样式的注释。它将缩短//太长的行,但不会将太短的行连接在一起。

    3 回复  |  直到 9 年前
        1
  •  2
  •   JesperE    16 年前

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

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

    确保启用了“启用XXX注释格式”。

        2
  •  1
  •   Dónal    16 年前

    我从来没有真正能够让Eclipse格式化程序格式化我的代码 这只是我遇到的几个缺点之一。我听说老爷车造型师好多了。两者都有 commercial free 两个版本都可以使用Eclipse插件。我听说商业版更为复杂(免费版的开发似乎已经停滞),但我并没有亲自使用过。

        3
  •  1
  •   Dustin Biser    12 年前

    我的解决方案包括使用vrapper插件(免费): http://vrapper.sourceforge.net/home/ 其中的vim编辑器为您提供了文本支持。

    安装vrapper插件后,您可以按 进入 ,突出显示多行注释,然后按 G+Q公司 自动设置注释格式,使行宽度为80列(默认值)。您可以更改默认列宽,但需要阅读vrapper插件的文档。干杯!

    推荐文章