如何禁用Eclipse PDT粘贴时的自动格式化代码功能

8
我正在使用 Eclipse Indigo 3.7.0 和 PDT 进行 PHP 开发。 当我复制/粘贴一些代码时,Eclipse 会自动格式化它。
例如,复制这个:
if ($distance > 50 && $distance  <= 100)    {$local_score = 8;}
if ($distance > 100 && $distance <= 200)    {$local_score = 6;}

这被粘贴在这里:
if ($distance > 50 && $distance  <= 100)    {
    $local_score = 8;
}
if ($distance > 100 && $distance <= 200)    {
    $local_score = 6;
}

有没有想法如何禁用这个功能? 最好的问候。
2个回答

16

这真的很糟糕...
试试这个。
用文本编辑器打开workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.php.ui.prefs。
添加"smartPaste=true"。

(请注意,我不知道是否有副作用)


1
我尝试了这个,目前运行良好,没有注意到任何副作用。非常感谢。 - Philippe
7
难道不应该是"smartPaste=false"而不是"true"吗? 对我来说"true"无效,但是"false"有效。 此外,您可以通过Eclipse首选项找到相应的配置选项:Window->Preferences->PHP->Editor->Typing->取消选中"When Pasting Adjust Indentation"(来源于http://roadzy.blogspot.com/2012/08/how-to-disable-auto-formatting-when.html) - Kipras
请注意“已回答 2011年7月5日11:28”。当时界面还没有实现。这是一个旧故事。 - atlanto

14
  • 进入"窗口/首选项"
  • 选择"Java/编辑器/键入"
  • 取消勾选复选框"When pasting"/"Adjust indentation"

这在Eclipse Luna Service Release 1 (4.4.1)下无法工作。 - a coder
是的,它确实可以与“Luna Service Release 1(4.4.1)”一起使用。这应该是首选解决方案。(如果对您不起作用,请撤销对“.ui.prefs”文件所做的更改,这可能导致错误) - phil294
1
这个问题涉及到PDT(PHP开发工具),虽然对一些人来说可能很明显,但是这个答案的第二步应该是然后选择页面*PHP*(而不是Java)/编辑器/打字。这在4.6.2版本仍然有效。 - Ben Johnson

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接