Preventing Eclipse Formatting for Specific Code Sections
When working with code that is formatted semantically across multiple lines, the Eclipse formatter can inadvertently alter the desired formatting. This can be particularly problematic for code like SQL statements, which become difficult to read and maintain when formatted by the IDE.
Eclipse 3.6 and Later: Using Off/On Tags
To address this issue in Eclipse 3.6 and later, a special comment syntax can be used to control formatting:
// @formatter:off ... // @formatter:on
Within these comment blocks, the Eclipse formatter will be disabled. To enable the formatter within these blocks, use // @formatter:on.
Configuring the Off/On Tags
Additional Considerations
By utilizing these off/on tags, developers can effectively prevent Eclipse from automatically formatting specific sections of Java code, maintaining the desired vertical formatting for ease of reading and maintenance.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3