I use Netbeans auto format (ctrl+alt+f) a lot. It's a very nice function!.
But I use StringBuffer.append() to generate some xml. I indent the .append parameter to represente the node structure of my xml.
msg.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
msg.append( "<root>");
msg.append( "<subNode/>");
my problem : the autoformat move all my parameters to the same column.
msg.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
msg.append("<root>");
msg.append("<subNode/>");
My question : How can I prevent the auto format to to modify my code on a section of my file. I'm hoping to found something similar to "editor-fold".
//<editor-noAutoFormatting>"
msg.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
msg.append( "<root>");
msg.append( "<subNode/>");
The question has already been ask :
There is unfortunately no answer for that. The idea of annotation is not implemented for formatting (or I don't find it).
So from now the only way to avoid this, is to select the text you want to format, without your xml part and then use format.
EDIT :
The only things I found to avoid autoformat to delete spaces is to use comments /* */
.The spaces between them will not be trim by Netbeans formatter.
Example :
msg.append(/* */"<subNode/>");.