Disabling Eclipse Code Formatter for Specific Code Sections
Maintaining code that requires vertical formatting, such as SQL statements written as Java strings, can be a challenge when using the Eclipse editor. The Eclipse formatter can deface the semantic formatting of such code, making it more difficult to read and maintain.
The Eclipse @formatter Comment
In Eclipse 3.6, a special comment can be used to disable formatting for specific sections of code. By placing the following comment before and after the code that should not be formatted:
// @formatter:off // @formatter:on
Users can prevent Eclipse from formatting that specific section.
Enabling Off/On Tags in Eclipse Preferences
To activate this feature, go to:
Configure Custom Comment Tags (Optional)
The default values for the Off/On tags are "@formatter:off" and "@formatter:on," but these values can be customized within the preferences.
Additional Notes
The above is the detailed content of How Can I Prevent Eclipse Code Formatter from Reformatting Specific Code Sections?. For more information, please follow other related articles on the PHP Chinese website!