Type CTRL+F in the search box in idea \/\*\*(\s|.)*?\*\/ \s : matches invisible characters . : matches any single character except '\n' ? : When the character immediately follows any one of the other qualifiers (*,+,?, {n}, {n,}, {n,m}), the matching pattern is non-greedy. Match fewer characters. Search bar uses regular expressions to search (/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/|[ \t]*//.*) The code that will search for all comments can be replaced with spaces. or search (/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/) Just search for the first and last comments Also searching for whitespace lines is \n\n Then global replace can remove the code space line.