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.
Comment and uncomment lines of code To add or remove a line comment, do one of the following: From the main menu, select Code | Comment with Line Comment. Press Ctrl+/ .
In this case, using a multi-line comment is our only option no matter how short our comment needs to be. Block comments are enclosed in slash-asterisk ( /*) and asterisk-slash ( */ ). To add a block comment in IntelliJ IDEA, press ⌥ ⌘ / macOS or Ctrl + Shift + / on Windows and Linux.
Ctrl + / ==> To comment/uncomment a line . Ctrl + Shift + / ==> To comment/uncomment block of code.
keyboardShortcut
Control + R - Replace
Type -->
\s//.*
Select .* in right top of replace window . then it will select all comment like this --> //
Thank you @Bas Leijdekkers
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.
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