Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of the use of the @Formatter:off and @Formatter:on annotations in eclipse to disable formatting for a piece of code.
public class Formatter {
/**
* The next piece of code is not formatted
* because of the @formatter annotations.
*/
// @formatter:off
public void nonFormattedMethod() {
int sum = 1 + 2 + 3 + 4 + 5;
}
// @formatter:on
/**
* Without the @formatter annotations the
* same piece of code is formatted as below.
*/
public void formattedMethod() {
int sum = 1 + 2 + 3
+ 4 + 5;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment