Community
Participate
Working Groups
Let's say I have something like $stm = 'CREATE TABLE queue(' . 'id INTEGER PRIMARY KEY,' . 'rec TEXT NOT NULL,' . 'subject TEXT NOT NULL,' . 'body TEXT NOT NULL,' . 'headers TEXT NOT NULL);'; Pressing CTRL+SHIF+F results in a single line string. I hope this is a bug and not by design or I get scared! :-) Furthermore the formatter doesn't use the colum limit as the HTML formatter does, so I have to scroll horizontally... and that's not good at all. I've found only one unacceptable workaround: @formatter:off/on on every multiline string. Please, add an option such as "Get your hands off my strings!!!" :-) or as suggested by the more professional friend Dawid Pakula on the Eclipse forum: 1. Initializer justification 2. Preserve new lines after "." operator Anyway the sense must be "Don't touch my strings!" :-) See ya! Rik
PS: I set this report as normal bug, but actually to me it's so important that I was thinking to get back to Indigo or jump on Juno (PDT 3.1.2 was the last one without this problem).
If I could vote for this bug, I would. @formatter:off/on is a workaround as you noted, but it's also rather kludgy.
Personally, I prefer this style of formatting: //@formatter:off return "<html>\n" . "<head>\n" . ' <title>' . $this->getPageTitle() . "</title>\n" . $this->getHead() . $this->getStyles() . "</head>\n" . "<body>\n" . $this->getTop() . $this->getBody() . $this->getBottom() . "</body>\n" . "</html>\n" ; //@formatter:on Either way, I agree - get your hands off my multi-line strings.
Never mind - I did vote for this bug. :-)
Verified behavior in Eclipse Mars
Mitigation factors/ partial workaround. Windows->preferences->php->code style->formatter-> edit (a custom style)->line wrapping->expressions->binary espressions OK, here "Do not wrap" should do nothing instead of bringing anything on a single line, BUT at least, - "Wrap only when necessary" usea the limits (e.g. width 80) and - "Every element on a new line" formats just the way I do manually. Obviously I can have a mix like $stm = 'CREATE TABLE queue(' . 'id INTEGER PRIMARY KEY,' . 'rec TEXT NOT NULL,' . 'subject TEXT NOT NULL,' . 'body TEXT NOT NULL,' . 'headers TEXT NOT NULL);'; and $a='aaaaaaa'.'bbbbbbbb'; but at least I don't find myself with lines of 2km to scroll horizontally. Can't wait to have back the old way when I could have my strings concatenation untouched. By the way I expect "Do not wrap" to actually do NOTHING instead of unwrapping my style. Otherwise you should call it "Unwrap" or "bring all on a single line".
I also want this. Ticket #454865 requests a solution to the more general problem of re-wrapping (the example given is array initializers).