2008-09-18 22:30 阅读 34

如何在Eclipse PDT中使用自动换行功能来​​处理PHP文件?

Programming PHP in Eclipse PDT is predominately a joy: code completion, templates, method jumping, etc.

However, one thing that drives me crazy is that I can't get my lines in PHP files to word wrap so on long lines I'm typing out indefinitely to the right.

I click on Windows|Preferences and type in "wrap" and get:

- Java | Code Style | Formatter
- Java | Editor | Typing
- Web and XML | CSS Files | Source

I've tried changing the "wrap automatically" that I found there and the "Line width" to 72 but they had no effect.

How can I get word wrap to work in Eclipse PDT for PHP files?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

4条回答 默认 最新

  • 已采纳
    dongliantong3229 dongliantong3229 2008-09-18 22:50

    This has really been one of the most desired features in Eclipse. It's not just missing in PHP files-- it's missing in the IDE. Fortunately, from Google Summer of Code, we get this plug-in Eclipse Word-Wrap

    To install it, add the following update site in Eclipse:

    AhtiK Eclipse WordWrap 0.0.5 Update Site

    点赞 评论 复制链接分享
  • drmg17928 drmg17928 2008-09-18 22:36

    It's a known enhancement request. Bug 35779

    点赞 评论 复制链接分享
  • doupian9798 doupian9798 2013-04-03 09:06

    Eclipse Word-Wrap Plug-In by Florian Weßling works well in Eclispe PDT (3.0.2).

    Installation and update sites

    It is recommended to restart Eclipse with -clean option immediately after installation.

    Eclipse Indigo 3.7: http://dev.cdhq.de/eclipse/updatesite/indigo/
    Eclipse Juno 4.2: http://dev.cdhq.de/eclipse/updatesite/juno/
    Eclipse Kepler 4.3: http://dev.cdhq.de/eclipse/updatesite/kepler/
    Eclipse Luna 4.4: http://dev.cdhq.de/eclipse/updatesite/luna/
    Eclipse Mars 4.5: http://dev.cdhq.de/eclipse/updatesite/mars/
    Eclipse Neon 4.6: Plugin not necessary.* Just press Alt-Shift-Y :)

    * See KrisWebDev's answer for more details and how to make word wrap permanent.


    After the installation of the plugin:

    • Context menu: Right click > Toggle Word Wrap
    • Menu bar: Edit > Toggle Word Wrap
    • Keyboard shortcut: Ctrl-Alt-E
    • Also you may: Edit > Activate Word Wrap in all open Editors

    There is no dedicated indicator for the current status of the word wrap setting, but you can check the horizontal scroll bar in the Editor.

    • Horizontal scroll bar is visible: Word wrap is disabled.
    • Horizontal scroll bar is absent: Word wrap is enabled.
    点赞 评论 复制链接分享
  • doucheng2053 doucheng2053 2016-05-08 17:55

    Finally something that works in 2016 with native support!

    You want the latest and newer NEON version of Eclipse since Bug 35779 is finally patched:

    • Use the Eclipse installer
    • Click on the top right "menu" icon and choose ADVANCED MODE
    • Select Eclipse IDE for PHP Developers with Product Version: Latest
    • Next ... Next, Finish

    Now you can toogle wordwrap manually using Alt+Shift+Y for EACH file! Boring!

    So if you're lucky, there's supposed to be a nice global setting lost in Window > Preferences > General > Editors > Text Editors > Enable Wordwrap but no, that's a trap, there's no GUI setting! At least at the time of writing.

    So I've found the hard way to set it globally (by default):

    1. Close Eclipse

    2. Find org.eclipse.ui.editors.prefs Eclipse settings file:

      find ~ -name org.eclipse.ui.editors.prefs -printf "%p %TY-%Tm-%Td %TH:%TM:%TS "

    If you're on a platform like macOS where the above command doesn't work, you can find the settings file in your current workspace folder under .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs.

    1. Add:


    点赞 评论 复制链接分享