6

I need to modify a code but it has so many unused comments like this:

/*   6:    */ import java.util.List;
/*   7:    */ import org.apache.ibatis.session.SqlSession;
/*   8: 7  */ import org.apache.ibatis.session.SqlSessionFactory;
/*   9:    */ import org.apache.log4j.LogManager;
/*  10:    */ import org.apache.log4j.Logger;
Midoes
  • 89
  • 1
  • 4
  • 9

1 Answers1

8

I can give one alternative way .I 'm using this method.

There is a option search and replace in netbeans. Enable regex option and then type a regex to match the comments and replace with empty character. go to edit menu and then replace.

use regex

/\\*.*?\\*/

to match /*comment*/ style comment

edit > replace

example

enter image description here

I think it's not hard to create a netbeans addon to do this with a button .

Also rectangular selection tool can be helpful some times if the area is a rectangle

example

enter image description here

Madhawa Priyashantha
  • 9,633
  • 7
  • 33
  • 60
  • 1
    There is a risky case, if you have defined url in your class, this regular expression will be replace "//" symbols also. For example : String url = "http://www.google.com"; will be replaced to String url = "http:www.google.com"; – totali Feb 26 '17 at 06:31
  • 1
    agreed, any URLs within the CSS (for example /image/123.jpg) are now just 123.jpg, the / and insides are removed! Nice answer though and great GIFs, great effort put into the answer indeed. I think they should use yours but maybe manually supervise it! :) – AlexHighHigh Jan 07 '19 at 18:11