views:

72

answers:

2

Is there a command-line Unix tool that will format/indent/prettify source code in different languages? I'm especially interested in Java, JavaScript, PHP, and XML, but ideally it would handle others.

(I'm not looking for something to generate syntax-highlighting markup; I already know of a few tools that do that.)

A: 

Check out indent and enscript.

Ewan Todd
A: 

It's not trivial to do from the command line, but I've always found Vim's code formatter a great option. It is aware of many languages and can be reasonably customized.

jheddings