Disabling Eclipse code formatting for part of a javadoc

You can disable formatting for the header, but I don't believe you can selectively disable formatting for nonheader javadoc comments.


Been a while since this was asked/answered and helped me refine the following answer, hopefully additionally useful. I use this alternative as I wanted to run Javascript in Javadocs.

Eclipse provides the @formatter:off and @formatter:on which needs to be enabled via Windows->Preferences->java->code style->formatter:::edit button::: tab "off/on tags". They may be used in any comments.

Around the doc stuff

// @formatter:off
/**
* javadoc
*/ 
// @formatter:on

But when you want the formatter off within the javadoc use the @formatter:xxx within html comments <!-- xxxxx --> to indicate what you are trying to do. Use the <code>...</code> bloack to ensure no formatting and the inclusion of code as javascript.

Editted the code statements in the example as I wanted this to work on eclipse and netbeans. I found the formatter:off work but then stopped working on a different version of eclipse (yes I use multiple IDE versions).

/** 
* <br><!-- @formatter:off -->
* <code>
* <script type="text/javascript">
* // hash structure for holding variable as name and its text
* var hashText = {};
*  
* // function causes a hyper-link to be created
* function insertLink(varName, text){
*    var link22;
*  
*    hashText[varName] = text;
*  
*    link22 = '<a href="./ConsoleCapture.html#' + varName + '">' + hashText[varName] + '</a>';
*       
*    document.write(link22);
* }
* function insertLinkA(varName){
*    var link22;
*
*    link22 = '<a href="./ConsoleCapture.html#' + varName + '">' + hashText[varName] + '</a>';
*
*    document.write(link22);
* }
*      
* function setLinkPoint(varName, text){
*     hashText[varName] = text;
*      
*     document.write('<a id="' + varName + '"><U>' + hashText[varName] + '</U></a>');
* }
*      
* function setLinkPointA(varName){
*    document.write('<a id="' + varName + '"><U>' + hashText[varName] + '</U></a>');
* }
* </script>
* <code>
* <!-- @formatter:on -->
*
*
*/