4

Given a code line like this:

[..]
    stampsCollector.addStamp(stampId, isFamous, isDamaged, currentlyAvailable, value);
[..]

is there a convenient way to reformat it into this in Netbeans?

[..]
    stampsCollector.addStamp(
       stampId, 
       isFamous, 
       isDamaged, 
       currentlyAvailable, 
       value
);
[..]

I don't really mind how this is accomplished: e.g. either during reformatting on-save, or by hitting a custom keyboard-shortcut in each line or by using a recorded macro ...

At the current moment, I keep finding me manually reformatting lots of code lines which is quite time consuming.

SebastianRiemer
  • 1,495
  • 2
  • 20
  • 33

2 Answers2

7
Tools -> Options -> Editor -> Formatting -> Language: Java -> Category: Wrapping

Select "Method Parameters" and set it to Always. Using SHIFT + ALT + F will now automatically break those lines.

Seth
  • 1,545
  • 1
  • 16
  • 30
  • Looks quite good - is there a way to change the behavior so that the first parameter is also formatted in a new line? I don't really like that the first parameter is printed next to the method name - not sure if you understand what I am trying to say. – SebastianRiemer Feb 18 '16 at 13:52
  • @SebastianRiemer I get your point, but I'm not aware of any way to do this :/ – Seth Feb 18 '16 at 14:48
  • Ok thanks, I'll use this feature - having a way to format method parameters in a standard way automatically is really great and saves a lot of time. I guess I'll get used to the first param not being printed in a separate line. – SebastianRiemer Feb 19 '16 at 11:12
0

Open file in any decent editor (notepad ++) Replace ( with (\n with regex mode on.

Cozimetzer
  • 662
  • 4
  • 12