views:

1209

answers:

4

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.

A: 

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.

Pekka
have u used it? is it good?
weng
Yes. It's all right, and quite flexible in defining custom coding conventions. There is a fully functional trial, check it out to see whether it's for you.
Pekka
it looks like that eclipse is the right tool for me and its free=)
weng
I've used Polystyle. My biggest gripes are that it doesn't seem to handle formatting arrays within arrays and it doesn't seem to handle indentation that is a mix of tabs and spaces.
Timothy
@Timothy interesting points. The former would definitely be worth a bug report I think. I filed a bug (in the CSS parsing of multiple class names `.classname1.classname2 {}` and the author sorted it pretty quickly.
Pekka
+5  A: 

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).

Gordon
`Ctrl` `Shift` `F`. Note that in Eclipse you can also set up Save Actions that format your code when saving.
Paul Lammertsma
A: 

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.

Rich Adams
+3  A: 

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

6bytes