Remove all comments Eclipse shortcut

I successfully decompiled my old game and have transferred code to eclipse but the decompiler must think he is funny because it has literally put a comment on every line. Is there a way to quickly remove all the comments from a source file or do I have to do this all manually?

Use eclipse’s Find/Replace (google that if you don’t know)

In fact, here is the regex for this exact situation it appears: http://stackoverflow.com/questions/10530055/eclipse-find-replace-with-regex-to-comment-lines?lq=1

What regex would I use? I’ve tried the ones on stakc overflow and it says no matches.

What do the comments look like?

Also: http://regexpal.com/ is great for figuring these out.


/* 1:  */ package com.pickens.arcade.controllers.score;
/* 2:  */ 
/* 3:  */ public class ScoreController
/* 4:  */ {
/* 5:  */   public static int score;
/* 6:  */   
/* 7:  */   public static void init()
/* 8:  */   {
/* 9:8 */     score = 0;
/* ::  */   }
/* ;:  */ }



/* Location:           Z:\Users\iBGEnt\Dropbox\Zombie Nauts\ZN 0.4.5 Mac 2\ZN 0.4.5.jar

 * Qualified Name:     com.pickens.arcade.controllers.score.ScoreController

 * JD-Core Version:    0.7.0.1

 */

this is one class. I have never used find and replace before.

/\*.*?\*/ From the SO post seems to remove the line nums just fine on regexpal, but you’ll have to remove the description(s) at the bottom yourself.

Just Ctrl-F in the editor, put /\*.*?\*/ in the Find field, leave ‘Replace with’ blank (to replace the comments with nothing, effectively removing them), check ‘Regular Expressions’, and then click ‘Replace All.’

Thanks! one more thing, the weird decompiler replaced my formatting from tabs to spaces, is there a quick fix for that too?

Find: * enter number of spaces for each tab *
Replace: * tab *

Un-check regular expressions. Click.

That find and replace tool works magic! Thanks man!

Pro tip: most editors have this functionality. (although things like word processors probably don’t often include regex ability…)