如何让 PHP 文件在 Eclipse PDT 中自动换行?
在 Eclipse PDT 中对 PHP 进行编程主要是一种乐趣:代码完成、模板、方法跳转等。
然而,让我发疯的一件事是我无法将 PHP 文件中的行自动换行,所以在长行中我无限期地向右打字。
我单击“Windows|首选项”并输入“换行”并得到:
- Java | Code Style | Formatter
- Java | Editor | Typing
- Web and XML | CSS Files | Source
我尝试将在那里找到的“自动换行”和“线宽”更改为 72,但它们没有效果。
如何让 PHP 文件在 Eclipse PDT 中自动换行?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这确实是 Eclipse 中最受欢迎的功能之一。 它不仅在 PHP 文件中缺失,而且在 IDE 中也缺失。 幸运的是,从 Google Summer of Code 中,我们得到了这个插件 Eclipse Word-Wrap
要安装它,请在 Eclipse 中添加以下更新站点:
AhtiK Eclipse WordWrap 0.0.5 更新站点
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
这是一个已知的增强请求。 错误 35779
It's a known enhancement request. Bug 35779
终于在 2016 年有了本地支持的东西了!
您需要自 Bug 以来最新的 NEON 版本的 Eclipse 35779 终于修补完毕:
高级模式
适用于 PHP 开发人员的 Eclipse IDE
以及产品版本:最新
现在您可以使用 Alt+Shift+Y 为每个文件手动切换自动换行! 无聊的!
所以如果你幸运的话,应该有一个不错的全局设置迷失在
窗口
>首选项
>常规
>编辑器
>文本编辑器
>启用自动换行
但是不行,这是一个陷阱,没有 GUI 设置! 至少在撰写本文时是这样。所以我找到了全局设置它的困难方法(默认情况下):
关闭Eclipse
查找
org.eclipse.ui.editors。 prefs
Eclipse 设置文件:find ~ -name org.eclipse.ui.editors.prefs -printf "%p %TY-%Tm-%Td %TH:%TM:%TS\n"
如果您使用的是 macOS 等平台,上述命令不起作用,您可以在当前工作区文件夹中的
下找到设置文件。元数据/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs
。添加:
wordwrap.enabled=true
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:
ADVANCED MODE
Eclipse IDE for PHP Developers
with Product Version:Latest
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):
Close Eclipse
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
.Add:
wordwrap.enabled=true
Florian Weßling 的 Eclipse 自动换行插件 在 Eclispe PDT (3.0 .2).
安装和更新站点
建议在安装后立即使用
-clean
选项重新启动 Eclipse。Eclipse Indigo 3.7: http://dev.cdhq.de/eclipse/updatesite/indigo/< br>
Eclipse Juno 4.2: http://dev.cdhq.de/eclipse/updatesite/juno/< /a>
Eclipse Kepler 4.3: http://dev.cdhq.de/eclipse/updatesite/kepler/< /a>
Eclipse Luna 4.4: http://dev.cdhq.de/eclipse/updatesite/luna/< /a>
Eclipse Mars 4.5:http://dev.cdhq.de/eclipse/updatesite/mars/< /a>
Eclipse Neon 4.6:不需要插件。* 只需按 Alt-Shift-Y :)
* 请参阅 KrisWebDev 的回答了解更多详细信息以及如何使自动换行永久。
用法
安装插件后:
没有专门的指示器来指示自动换行设置的当前状态,但您可以检查编辑器中的水平滚动条。
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:
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.