php: auto indent the whole code?

。_饼干妹妹 提交于 2019-12-22 03:49:05

问题


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

not just indent when i press ENTER for new function.

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.


回答1:


In Zend Studio (and I guess in Eclipse with PDT as well), you can right click your pasted document in the editor view and select Source Format. Rules for source formatting are edited in Windows Preferences PHP Code Style Formatter. You can select Code Conventions like PEAR or ZF there by default or invent your own.

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




回答2:


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




回答3:


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.




回答4:


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




回答5:


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.



来源:https://stackoverflow.com/questions/1932768/php-auto-indent-the-whole-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!