I have following code:
public int doBam(int bam) { if(foo) { bam += 1; if(bar) { bam += 1; } } return bam; }
I want to comment out the if(bar) ...
When I do toggle comment in Eclipse 3.6 I will get this:
public int doBam(int bam) { if(foo) { bam += 1; // if(bar) { // bam += 1; // } } return bam; }
Can I make Eclipse to toggle comment like this instead?
public int doBam(int bam) { if(foo) { bam += 1; //if(bar) { // bam += 1; //} } return bam; }
Ctrl - / to toggle "//" comments and Ctrl - Shift - / to toggle "/* */" comments.
Can I make Eclipse to toggle comment like this instead?
It's a three step process..
Step-1:- Select desired code.
if(bar) { bam += 1; }
Step-2:- Hit Control + 7 OR Control + /
// if(bar) { // bam += 1; // }
Step-3:- Hit Control + Shift + F
// if(bar) { // bam += 1; // }
UPDATE
Also, when uncommenting, the Eclipse autoformatter does not restore the previous indentation
Like commenting, uncommenting is also three step process:-
it applies it's own formatting rules instead.
You can change these formatting rules. Windows --> Preferences --> Java --> Code Style --> Formatter --> Edit --> Comments Tab.
Eclipse does not allow editing default built-in profile. Create new profile and inherit all the properties from built-in profile, then you can customize the newly created profile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With