1

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

8

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

0

Take a look at PhpStorm 9.0.0 Help / Commenting and Uncommenting Blocks of Code:

Commenting and uncommenting lines of code

Do one of the following:

On the main menu, choose Code | Comment with Line Comment.
Press Ctrl+Slash. 

Commenting and uncommenting blocks of code

To add or remove a block comment, do one of the following:

On the main menu, choose Code | Comment with Block Comment.
Press Ctrl+Shift+Slash. 
  • 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. – Ejaz Sep 8 '15 at 17:11
0

PHPStorm doesn't come with any predefined functions/plugins for deleting comments. The most obvious solution is regexp replacement. See also https://stackoverflow.com/questions/503871/best-way-to-automatically-remove-comments-from-php-code, https://stackoverflow.com/questions/22819768/removing-php-comments-with-replace-tool-using-regex-in-phpstorm for some hints.

  • That's how I currently do it. – Ejaz Sep 8 '15 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.