Is it possible to mark a part of java code in eclipse to be not auto formatted?
autoformatting, eclipse, format, formatting, java
Solution
I think you can use `@formatter:off` and `@formatter:on`
// @formatter:off
public void fluentIterfaceThingy() {
...
}
// @formatter:on
You might have to turn this option on in the code style section: `Window->Preferences->Java->Formatter->Edit->On/Of Tags`
Problem
Auto-Format by eclipse for java code is brilliant! You can write terrible code and then simple type CTRL+SHIFT+f - and the code is amazing. But, sometime I want to mark part of code to be not automatically formatted. For example by fluent interface: ``` public void fluentInterfaceJooqDemo() { create.select(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME, count()) .from(AUTHOR) .join(BOOK).on(AUTHOR.ID.equal(BOOK.AUTHOR_ID)) .where(BOOK.LANGUAGE.eq("DE")) .and(BOOK.PUBLISHED.gt(date("2008-01-01"))) .groupBy(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME) .having(count().gt(5)) .orderBy(AUTHOR.LAST_NAME.asc().nullsFirst()) .limit(2) .offset(1) .forUpdate() .of(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME); } ``` and after type CTRL+SHIFT+f ``` public void fluentInterfaceJooqDemo() { create.select(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME, count()).from(AUTHOR).join(BOOK).on(AUTHOR.ID.equal(BOOK.AUTHOR_ID)) .where(BOOK.LANGUAGE.eq("DE")).and(BOOK.PUBLISHED.gt(date("2008-01-01"))).groupBy(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME) .having(count().gt(5)).orderBy(AUTHOR.LAST_NAME.asc().nullsFirst()).limit(2).offset(1).forUpdate() .of(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME); } ``` However, I'm looking for some method to mark such code `non-autoformat`, e.g. ``` //non-format public void fluentInterfaceJooqDemo() { ... } ```