kjdion84
kjdion84

Reputation: 10044

PhpStorm Reformat Comments Automatically?

Is there any way for PhpStorm to automatically reformat all comments in my project? I've already changed the settings to use one-line comments but it doesn't seem to do anything when I run the code formatter.

For example, let's say I have the following comment:

    /*
     * Hello, I am a comment
     */

Is there any way for PhpStorm to auto-convert it to this:

    // Hello, I am a comment

I'd also want it to work for multi-line comments i.e.:

    /*
     * Hello, I am a comment
     * I'm on multiple lines
     */

Should become this:

    // Hello, I am a comment
    // I'm on multiple lines

Is it possible for PhpStorm to do this for my entire project automatically?

Upvotes: 0

Views: 57

Answers (1)

kjdion84
kjdion84

Reputation: 10044

Just ended up doing a regex replace:

find: \/\*\n(.*)\* (.*)\n(.*)\*\/
replace: // $2

That worked for my first comment, the one with multiple lines I just changed manually.

Upvotes: 1

Related Questions