Home >Java >javaTutorial >How Can I Prevent Eclipse from Formatting Specific Code Sections?
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.
The above is the detailed content of How Can I Prevent Eclipse from Formatting Specific Code Sections?. For more information, please follow other related articles on the PHP Chinese website!