Remove comments from file

11,038

Since the problem in this question hasn't received any solutions, I; for documentation and readers' help, am going to present the way I currently do it. The ideal solution has to be one-click and do following

  1. remove all comments in one click
  2. restore all comments back in one click

So my less than ideal solution is as follows

Remove all comments
1. use following regexp in find tool to replace all multi-line comments with empty /\*(\*)?(((?!\*/)[\s\S])+)?\*/
2. then use following regexp to replace all single-line comments with empty //.*$

Restore all comments
1. Open VCS > Local History > Show History and restore to the version with comments.

I'm still hoping to find a true one-click solution.

thanks

Share:
11,038

Related videos on Youtube

Ejaz
Author by

Ejaz

Updated on September 18, 2022

Comments

  • Ejaz
    Ejaz over 1 year

    I'm using PHPStorm and have a very basic problem. I want to remove single/multi/phpdoc comments from my files. I want this process to be one-click and easily undo-able. I've tried looking over the internet and in PHPStorm help but couldn't find any feature like this.

    There could be a PHPStorm plugin that performs this function? I've exhausted my resources in trying to find out the answer.

    I know I can use regular expression search replace in PHPStorm and other text editors to achieve this but I'm looking for more of a one click do/undo able solution.

    Any help will be greatly appreciated.

    Thanks

  • Ejaz
    Ejaz over 8 years
    That's how I currently do it.
  • Ejaz
    Ejaz over 8 years
    That serves a different purpose than I've stated in question. I want to remove the comment contents which is different from uncommenting a block and making it part of the code.