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.
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).
In Eclipse you can press Ctrl+Shift+f to autoindent your open file.
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.
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.
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.