Artistic Style (command line:
astyle) is a tool to format Java code (i.e. fix your indentation and new lines).
It also works on: C, C++, C++/CLI, Objective‑C, and C#.
astyle *.java at the command line on CSIL to use a software package called “Artistic Style” to automatically fix the indentation of your Java code to match a variety of style conventions.
As an example, if your directory contains:
cs56-rational-ex01 pconrad$ ls LICENSE Rational.java Main.java README.md cs56-rational-ex01 pconrad$
After you run
astyle *.java, you’ll have:
cs56-rational-ex01 pconrad$ ls LICENSE Main.java.orig Rational.java Main.java README.md Rational.java.orig cs56-rational-ex01 pconrad$
.java.orig file are the originals, and the
.java files are the newly formatted files.
You can use command line arguments to control which style is used, and to apply
astyle recursively to an entire directory tree:
| ||Apply Google style to all files under the |
Install on Mac
To install on Mac, first install MacOS: Homebrew, then type:
brew install astyle