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 WindowsLinux or ‘Cmd + W’ on Mac):

Invoke the ‘Surround With’ (‘Ctrl + Alt + T’ on WindowsLinux 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!

This entry was posted in Cool Feature, PhpStorm and tagged , . Bookmark the permalink.
  • Kefaleas Stavros

    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!

  • Chris

    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

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

  • Dario De Lucia

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

  • MaximAL

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

  • Egor Ushakov

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

    • Andriy Bazanov

      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

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

  • Francesco

    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…