0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.