eclipse php:自动缩进整个代码?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1932768/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 14:13:52  来源:igfitidea点击:

php: auto indent the whole code?

phpeclipsenetbeansindentation

提问by ajsie

isnt there any software/plugin to netbeans/eclipse that auto indent the whole code after i've inserted it?

没有任何软件/插件可以在我插入后自动缩进整个代码的 netbeans/eclipse 吗?

not just indent when i press ENTER for new function.

当我按下 ENTER 以获得新功能时,不仅仅是缩进。

i want to paste in a code for example without indents and it will auto indent everything automatically since it can recognize what language is used.

我想粘贴一个代码,例如没有缩进,它会自动缩进所有内容,因为它可以识别使用的语言。

should save a lot of time.

应该可以节省很多时间。

回答by Gordon

In Zend Studio (and I guess in Eclipse with PDT as well), you can right clickyour pasted document in the editor view and select SourceFormat. Rules for source formatting are edited in WindowsPreferencesPHPCode StyleFormatter. You can select Code Conventions like PEAR or ZF there by default or invent your own.

在 Zend Studio 中(我猜在带有 PDT 的 Eclipse 中也是如此),您可以right click在编辑器视图中粘贴文档并选择SourceFormat. 源格式的规则在WindowsPreferencesPHPCode StyleFormatter. 默认情况下,您可以选择 PEAR 或 ZF 等代码约定,也可以自己发明。

If you just want to indent some selected lines of code back and forth you select it and hit tab(or shifttabto unindent). This will not resolve any nested code though. Use CtrlShiftFfor that (thanks to Paul Lammertsma for pointing that out).

如果您只想来回缩进某些选定的代码行,请选择它并点击tab(或shifttab取消缩进)。但这不会解析任何嵌套代码。CtrlShiftF为此使用(感谢 Paul Lammertsma 指出这一点)。

回答by 6bytes

In Eclipse you can press Ctrl+Shift+f to autoindent your open file.

在 Eclipse 中,您可以按 Ctrl+Shift+f 自动缩进打开的文件。

回答by John Zammit

In Netbeans go to the Source menu, choose the Format option. It does what you need. It will follow the formatting options you set from Tools menu, Options dialog.

在 Netbeans 中,转到“源”菜单,选择“格式”选项。它可以满足您的需求。它将遵循您从“工具”菜单的“选项”对话框中设置的格式选项。

回答by Pekka

Polystyleis a standalone tool that can be integrated into most IDEs, and does highly configurable source code formatting for many languages. It costs $15.

Polystyle是一个独立的工具,可以集成到大多数 IDE 中,并为多种语言进行高度可配置的源代码格式化。费用为 15 美元。

回答by Rich Adams

I believe the Eclipse shortcut to auto-indent the selected code is Ctrl+i, at least it is in Eclipse for Java, so I assume it would be the same for Eclipse PHP.

我相信自动缩进所选代码的 Eclipse 快捷方式是 Ctrl+i,至少它在 Eclipse for Java 中是这样,所以我认为它对于 Eclipse PHP 来说是一样的。