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

4

52

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?

Formicary answered 18/9, 2008 at 22:30 Comment(1)
I think @Fedir's answer should be the accepted answer as it has the most updated pluginsUnhorse
S
66

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

Schoenfeld answered 18/9, 2008 at 22:50 Comment(5)
Installed it in 3 minutes and now I have word-wrap, WONDERFUL, thanks.Formicary
Link is not working. Error msg : "Error establishing a database connection"Spontaneity
Seems his entire website is down :( hope it is temporary.Schoenfeld
I've installed it, but it needs to be enabled it on every single page. I want to check it once for all. Someone with a similar problem ?Troytroyer
This plugin is not maintained and now doesn't work for newest Eclipse. Look for Fedir's answer below!Fungal
M
15

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.
Mariande answered 3/4, 2013 at 9:6 Comment(6)
This is the correct solution. The previous plugin stopped working with newest Eclipse.Fungal
Newer links: Eclipse Kepler 4.3: dev.cdhq.de/eclipse/updatesite/kepler Eclipse Luna 4.4: dev.cdhq.de/eclipse/updatesite/luna Eclipse Mars 4.5: dev.cdhq.de/eclipse/updatesite/mars An Eclipse restart will be required after installation.Digitalism
@Digitalism I, J, K, L, M, N... added :)Redvers
@EdwardTanguay Consider accepting this answer instead, as it covers all versions from Indigo to Neon. For Neon (where word wrap is a base feature), it has a reference to KrisWebDev's answer for more detail. The current accepted answer points to a plugin that is outdated and no longer maintained - it only works with very old Eclipse versions.Redvers
@Redvers you were luckier than me. In November I tried editing the question before leaving this comment. This was rejected stackoverflow.com/review/suggested-edits/10375180 with a logic I am entirely unable to follow...Digitalism
@Digitalism Not lucky. Privileged ;) PS: I agree that the logic is 100% flawed. I would have approved your edit if I was on the panel. That link itself says: "add addendums / updates as the post ages" as one of the reasons you should edit a page.Redvers
V
10

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\n"

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:

    wordwrap.enabled=true

Valgus answered 8/5, 2016 at 17:55 Comment(3)
Thanks. Confirmed working in Eclipse for Java as well. I think it should work with any Eclipse flavor, not limited to PHP, as it's a base feature. Mind generalizing your step 3 (select your choice of Eclipse with Product Version: Latest (Neon))? Also, removing your rants would make a quality answer ;)Redvers
This should accepted answer. At last "eclipse" has built-in "word wrap" feature. Thanks for answer.Siebert
on windows installations, the file is in the workspace at <workspace>\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.ui.editors.prefsHankins
V
9

It's a known enhancement request. Bug 35779

Valeta answered 18/9, 2008 at 22:36 Comment(2)
What a shame for such an elegant IDE. :'(Meier
Yeah, not just this, Eclipse has notoriously lacked basic editor functionalities, and it doesn't look like they care enough to do something about it (fast enough; at least they fixed something in Neon). Not just the missing word wrap functionality, the toolbar (which is a pain to manage) doesn't have Undo/Redo buttons! I have to use another plugin to add them.Redvers

© 2022 - 2024 — McMap. All rights reserved.