문제

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/>");.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top