In addition to the awesome answers which work using the Find & Replace
module for IDEA Jetbrains, you could also use a shell command since the terminal is readily available within the Jetbrains products for Linux and Mac systems. the good old sed
command is super handy. Additionally this is useful for repeating the action for many files. The commands slightly differ for Mac and Linux. For Mac, you would need the extra '' as shown below so that backup files are not created.
For completeness, included the commands for python as well along with C and java.
Linux command for C and Java,
sed -i '/^[[:space:]]*\/\//d' filename.java
sed -i '/^[[:space:]]*\/\//d' filename.C
sed -i '/^[[:space:]]*#/d' filename.py
As mentioned before, for Mac, extra '' are needed:
sed -i '' '/^[[:space:]]*\/\//d' filename.java
sed -i '' '/^[[:space:]]*\/\//d' filename.C
sed -i '' '/^[[:space:]]*#/d' filename.py
String s = "//my string";
. – Sower