I have some big files in my project with many lines commented.
Usually when I change something in my code, I comment unnecessary lines first and after testing remove them.
But sometimes at the end there are too many comments in a big file, and it is hard to remove them.
So, may be there is some function in Android Studio to 'clean up' file from comments (excluding javadoc comments, of course) like 'Organize imports' for removing unused imports in file.
Or, maybe, some kind of highlighting commented lines, so I can easily see what to remove.
Can you help me with that?
Any ideas are appreciated
📝 Usage. Once installed, remove comments in your code by opening the command palette ( Ctrl + Shift + P ), entering "Remove all comments" and pressing enter. Voilà, all the comments are gone 🎉 !
Try with regex, to replace the match with nothing
This page suggest :
(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/)|(//.*)
This is also matching the Javadocs, so you would have to tweak it a bit. There are also other variations that you can try.
Have a look at this other SO question. It is suggesting to use an ANT task that is processing the comments and strip them from the source. In this way you can have a button or keyboard shortcut that is calling the ANT task.
As suggestion put a Label in the history before doing big search and replace so later you can compare if want to restore any comments that may have been stripped.
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