How to disable Eclipse PDT auto-format code when pasting
Asked Answered
T

2

8

I'm using Eclipse Indigo 3.7.0 with PDT for PHP develpment. When I copy/paste some code, Eclipse automatically format it.

For example, copying this :

if ($distance > 50 && $distance  <= 100)    {$local_score = 8;}
if ($distance > 100 && $distance <= 200)    {$local_score = 6;}

Is pasted in this :

if ($distance > 50 && $distance  <= 100)    {
    $local_score = 8;
}
if ($distance > 100 && $distance <= 200)    {
    $local_score = 6;
}

Any idea on how to disable this ? Best Regards.

Toupee answered 5/7, 2011 at 10:10 Comment(0)
F
16

It's really bad...
Try this.
Open workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.php.ui.prefs by your text editor.
Add "smartPaste=true".

(note that I'm not aware of side effect)

Friedrich answered 5/7, 2011 at 11:28 Comment(3)
I tried this and it`s working well. No side effect noticed for now. Thank you so much.Toupee
Isn't it supposed to be "smartPaste=false", instead of "true" ?? "true" didn't work for me, but "false" did. Also, you can find the corresponding configuration option through Eclipse preferences: Window -> Preferences -> PHP - > Editor -> Typing -> Uncheck "When Pasting Adjust Indentation" (courtesy of roadzy.blogspot.com/2012/08/…)Buell
Pay attention to "answered Jul 5 '11 at 11:28". On that day, UI had not been implemented yet. This is an old story.Friedrich
J
15
  • Go to Window / Preferences
  • Then select page Java / Editor / Typing
  • Then unselect checkbox "When pasting" / "Adjust indentation".
Jackknife answered 9/10, 2014 at 8:51 Comment(3)
This did not work under Eclipse Luna Service Release 1 (4.4.1).Frankhouse
Yes, it very much indeed does work with Luna Service Release 1 (4.4.1). This should be the preferred solution. (If it does not work for you, undo the change to the .ui.prefs file which might have caused the error)Rosewood
This question is regarding PDT (PHP Developer Tools), and while this may be obvious to some, the second step of this answer should be Then select page *PHP* (not Java) / Editor / Typing. This still works in 4.6.2.Forefend

© 2022 - 2024 — McMap. All rights reserved.