Indenting code?
Weijun Wang
weijun.wang at oracle.com
Thu Sep 13 17:59:38 PDT 2012
On 09/14/2012 08:21 AM, Brad Wetmore wrote:
> Netbean's automatic formatting does a pretty good job with new code.
That's Alt-Shift-F, which I rarely dare to press, because it change
existing codes.
In fact, NetBeans is doing very smart indentation while you are coding,
at least it adheres to the Sun/Oracle convention. The only thing I need
to care about is breaking long lines.
I also turn on Options|Editor|General|Remove Trailing Whitespace From
Modified Lines Only.
> However, I think the general advice is to not change existing code just
> because. When you're dealing with multiple release families, it makes
> the merges much more difficult.
Yes, yes, yes, and it makes code reviewers wondering what really changed.
-Max
>
> Brad
>
>
>
> On 9/13/2012 6:18 AM, John Zavgren wrote:
>> Greetings:
>>
>> I have a simple question about how to enforce code styles for: java,
>> c, and c++. I know there are style guides that legislate the
>> indentation, "curly brace and parenthesis management", etc.
>>
>> I'm looking for a simple automatic way to transform any source code
>> file so that it's image is guaranteed to be "correct". No thinking
>> required.
>>
>> What I normally do is use an open source tool named "indent", e.g.,
>>
>> indent -bap -bbb -bl -nce -l80 file1.cpp file2.h file3.c file4.java
>>
>> And, I put an "indent" target in my make files.
>>
>> Consequently whenever I make something, the very first step is to
>> format the code, and I know that when I do a check in later on... I
>> never have to think about whether or not the code conforms to a style
>> guide... because the options I gave to "indent" implemented this
>> guide. (You can do similar things with emacs too.)
>>
>>
>> Any ideas?
>>
>> Thanks!
>> John Zavgren
>> john.zavgren at oracle.com
>>
More information about the net-dev
mailing list