New in 3.0: More ‘Surround With’ actions for PHP


There are new ‘Surround With’ actions introduced in PhpStorm 3.0

Surround with: ‘(expr)’ and ‘!(expr)’

This couple of actions can help you quickly surround expressions with braces or negate logical expressions.

Suppose you want to negate some expression. Select the expression using the ‘Select Word at Caret’ action (‘Ctrl+W’ on Windows\Linux or ‘Cmd + W’ on Mac):

Invoke the ‘Surround With’ (‘Ctrl + Alt + T’ on Windows\Linux or ‘Cmd +Option + T’ on Mac) action and select ‘!(expr)’:

The cursor will be placed at the end of the expression:

Surround with: ‘if(expr){…}’ and ‘while(expr){…}’

You probably remember our blogpost about writing assignments with ‘Introduce Variable’ refactoring. This time we want to introduce you another hint in quick writing ‘if’ and ‘while’ statements.

Suppose you want to write the following ‘if’ statement:

Let’s start writing it using the ‘Surround With’ action. First of all, write the condition:

Select the condition:

Invoke the ‘Surround With’ action and select ‘if(expr){…}’:

Then start typing the ‘if’ statement body:

Develop with pleasure!

Comments below can no longer be edited.

12 Responses to New in 3.0: More ‘Surround With’ actions for PHP

  1. Kefaleas Stavros says:

    February 8, 2012

    I bought the excellent web storm 3 package.
    I think I’ll wait for an offer for php storm 3!
    Keep up the good work!

  2. Chris says:

    February 8, 2012

    The count($options) > 0 doesn’t work for me. Or rather it worked once, now I can’t get the surround options beyond 2 to appear again. I got about 10 of then the first time…

    Thanks for fixing the uppercase Javascript and unresolved images blocking the code parser though. It’s nice to be able to rely on phpStorm again! Looks like you might need to test a bit longer for the feature above…

    • nnmatveev says:

      February 10, 2012

      Please submit an issue about your case. Thank you for feedback!

  3. Dario De Lucia says:

    February 9, 2012

    Guys you are just doing a great work! Keep going on!

  4. MaximAL says:

    February 12, 2012

    Parentheses around array_ky_exists are redundant.
    IDEA can process theese particular cases.

  5. Egor Ushakov says:

    February 12, 2012

    This is strange but I found no ‘Select successively increasing code blocks’ action at Preferences -> IDE Settings -> Keymap

    • Andriy Bazanov says:

      February 15, 2012

      It’s called “Select Word at Caret” (under “Editor Actions” or “Main Menu | Edit”). Maybe it is called differently in upcoming version 4 or in IntelliJ IDEA?

      • nnmatveev says:

        February 17, 2012

        Thanks, guys! Actually I used the name from keymap reference card, which is more descriptive, but can confuse. I have fixed the post.

  6. Francesco says:

    February 17, 2012

    Well, I used to believe that the vast majority of the praises that you can read on a product website are fake and written by the same software authors. After almost one year of PHPStorm usage I changed my mind: you deserve any praise and appreciation because IMHO this is one of the coolest piece of software I ever tried, but the better part for me is that is backed up by one of the best support team I have ever found. Thank you, Thank you…