Search code examples
javaintellij-ideaide

How to delete all comment lines in IDEA?


I´m searching for a quick way to get rid of all comments in a file.

Looking for a keyboard shortcut or a quick and easy alternative.

Any suggestions?

EDIT

I would like particularly to delete only the out commented lines, so ones that start with //, not the block comments - which normally are meant for java-doc.


Solution

  • You could use Find & Replace (Ctrl/Cmd+R). Search In Comments Only (option under the little cog menu), enable regex search and search for string ^//.*. Replace with the empty string.