views:

6180

answers:

5

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  A: 

It's a known enhancement request. Bug 35779

Turnkey
A: 

Why do you have long lines in your code? I know this isn't answering your question, but coding in extreemly long lines is going to make things difficult to maintain. Personally I try to keep my lines as short and to the point as possible. That way when I, or someone else, has to go back into this code they don't have to spend trying to figure out what is going on:

i.e:

$myStr = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. '
       . 'Integer dignissim eros ut tortor. Quisque blandit elementum '
       . 'mi. Phasellus pellentesque ligula a neque. Donec pede. Suspendisse '
       . 'at enim. Aenean sed libero. Donec velit massa, consectetuer sit amet, '
       . 'vehicula at, ultricies rutrum, sem. Etiam quis pede quis nisi '
       . 'pellentesque consequat. Vivamus sodales mattis dolor. Curabitur mattis. '
       . 'Vivamus scelerisque urna eu metus. Nunc nibh lacus, ultricies sit amet, '
       . 'porttitor a, cursus tempor, lacus. Quisque convallis lorem vitae lacus '
       . 'dapibus scelerisque.'

Instead of

$myStr = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer dignissim eros ut tortor. Quisque blandit elementum mi. Phasellus pellentesque ligula a neque. Donec pede. Suspendisse at enim. Aenean sed libero. Donec velit massa, consectetuer sit amet, vehicula at, ultricies rutrum, sem. Etiam quis pede quis nisi pellentesque consequat. Vivamus sodales mattis dolor. Curabitur mattis. Vivamus scelerisque urna eu metus. Nunc nibh lacus, ultricies sit amet, porttitor a, cursus tempor, lacus. Quisque convallis lorem vitae lacus dapibus scelerisque.';

Lets me easily identify that I've got a very large string that I'm placing in a variable and I'm not doing any variable substitutions in the middle or appending any thin but the text.

The second style would force me to scroll out to the end of the line to verify what is being stored (not everyone uses the same IDE, some people use command line tools). This may make it a little more difficult to maintain your formatting if you have large strings like this, but you'll find it make tracking down issues so much easier.

Rob Booth
+14  A: 

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 (still in alpha): http://ahtik.com/blog/2006/06/18/first-alpha-of-eclipse-word-wrap-released/

Swati
Installed it in 3 minutes and now I have word-wrap, WONDERFUL, thanks.
Edward Tanguay
+3  A: 

Why do we have long lines in our code? That's really simple. Sometimes the code isn't ours to start with, and besides editing the code to create manual linebreaks, this could also mean rewriting the code to get it right. That's no option in 99% of the cases.

Word wrap is a basic requirement. The fact that you don't need it is fine, we don't say that you have to use it!

A: 

Does Rob have another good choice :) ?

Ken Thomas