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

Solution 1:

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

Solution 2:

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.

Usage

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.