Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 254
Macilias Avatar asked Nov 26 '15 08:11

Macilias


People also ask

How do I delete all comments in IntelliJ?

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+/ .

How do I comment multiple lines in IntelliJ?

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.

How do I comment out a block of code in IntelliJ?

Ctrl + / ==> To comment/uncomment a line . Ctrl + Shift + / ==> To comment/uncomment block of code.


2 Answers

if you are using android studio 4 above

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

like image 157
lava Avatar answered Oct 05 '22 00:10

lava


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.

like image 45
Bas Leijdekkers Avatar answered Oct 05 '22 00:10

Bas Leijdekkers