如何让自动换行在 Eclipse PDT 中为 PHP 文件工作?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/97663/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I get word wrap to work in Eclipse PDT for PHP files?
提问by Edward Tanguay
Programming PHP in Eclipse PDT is predominately a joy: code completion, templates, method jumping, etc.
在 Eclipse PDT 中编程 PHP 主要是一种乐趣:代码完成、模板、方法跳转等。
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.
但是,让我发疯的一件事是,我无法让 PHP 文件中的行自动换行,因此在长行中我无限期地向右输入。
I click on Windows|Preferences and type in "wrap" and get:
我点击 Windows|Preferences 并输入“wrap”并得到:
- 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.
我尝试将我在那里找到的“自动换行”和“线宽”更改为 72,但它们没有效果。
How can I get word wrap to work in Eclipse PDT for PHP files?
如何让自动换行在 Eclipse PDT 中为 PHP 文件工作?
回答by Swati
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
这确实是 Eclipse 中最需要的特性之一。它不仅在 PHP 文件中缺失——它在 IDE 中也缺失。幸运的是,我们从 Google Summer of Code 中得到了这个插件Eclipse Word-Wrap
To install it, add the following update site in Eclipse:
要安装它,请在 Eclipse 中添加以下更新站点:
回答by Fedir RYKHTIK
Eclipse Word-Wrap Plug-Inby Florian We?ling works well in Eclispe PDT (3.0.2).
Florian We?ling 的Eclipse Word-Wrap Plug-In在 Eclispe PDT (3.0.2) 中运行良好。
Installation and update sites
安装和更新站点
It is recommended to restart Eclipse with-cleanoption immediately after installation.
建议在安装后立即使用选项重新启动 Eclipse -clean。
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:)
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:不需要插件。* 只需按Alt- Shift- Y:)
* See KrisWebDev's answerfor more details and how to make word wrap permanent.
* 有关更多详细信息以及如何使自动换行永久化,请参阅KrisWebDev 的回答。
Usage
用法
After the installation of the plugin:
安装插件后:
- Context menu: Right click> Toggle Word Wrap
- Menu bar: Edit> Toggle Word Wrap
- Keyboard shortcut: Ctrl-Alt-E
- Also you may: Edit> Activate Word Wrap in all open Editors
- 上下文菜单:右键单击>切换自动换行
- 菜单栏:编辑>切换自动换行
- 键盘快捷键:Ctrl- Alt-E
- 您也可以:在所有打开的编辑器中编辑>激活自动换行
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.
自动换行设置的当前状态没有专门的指示器,但您可以检查编辑器中的水平滚动条。
- Horizontal scroll bar is visible: Word wrap is disabled.
- Horizontal scroll bar is absent: Word wrap is enabled.
- 水平滚动条可见:自动换行被禁用。
- 没有水平滚动条:启用自动换行。
回答by KrisWebDev
Finally something that works in 2016 with native support!
终于可以在 2016 年使用本机支持了!
You want the latest and newer NEONversion of Eclipse since Bug 35779is finally patched:
您需要最新和更新的 Eclipse NEON版本,因为错误 35779终于被修补了:
- Use the Eclipse installer
- Click on the top right "menu" icon and choose
ADVANCED MODE - Select
Eclipse IDE for PHP Developerswith Product Version:Latest - Next ... Next, Finish
- 使用Eclipse 安装程序
- 单击右上角的“菜单”图标并选择
ADVANCED MODE - 选择
Eclipse IDE for PHP Developers与产品版本:Latest - 下一步 ... 下一步,完成
Now you can toogle wordwrap manually using Alt+Shift+Yfor EACH file! Boring!
现在,您可以手动换行的toogle使用Alt+ Shift+Y的每个文件!无聊的!
So if you're lucky, there's supposed to be a nice global settinglost in Window> Preferences> General> Editors> Text Editors> Enable Wordwrapbut no, that's a trap, there's no GUI setting! At least at the time of writing.
所以如果你幸运的话,应该会在> > > > > 中 丢失一个不错的全局设置,但是不,这是一个陷阱,没有 GUI 设置!至少在撰写本文时。WindowPreferencesGeneralEditorsText EditorsEnable Wordwrap
So I've found the hard way to set it globally(by default):
所以我发现了全局设置它的困难方法(默认情况下):
Close Eclipse
Find
org.eclipse.ui.editors.prefsEclipse settings file:find ~ -name org.eclipse.ui.editors.prefs -printf "%p %TY-%Tm-%Td %TH:%TM:%TS\n"
关闭日食
找到
org.eclipse.ui.editors.prefsEclipse 设置文件: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.
如果您在 macOS 等平台上上述命令不起作用,您可以在当前工作区文件夹下找到设置文件.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs。
Add:
wordwrap.enabled=true
添加:
wordwrap.enabled=true

