Using TextMate, how can I wrap everything in PHP tags


A question about TextMate. For example, I just typed var_dump($codes);, and I forgot to write <?php ?>. So, now I want to highlight the area that I want to wrap the php tags around. How can I do this?

Best Answer

  • Simply add a new command called for ex 'Wrap in ' in your php bundle editor (Bundles->Bundle Editors->Show Bundle Editor)

    In the Activation choose: Key Equivalent and hit: CMD+SHIFT+W (or whatever you'd like that's not already taken).

    Leave the scope selector to source.php

    In the snippet window write:

    <?php  $TM_SELECTED_TEXT ?>

    Now select anything and hit CMD+SHIFT+W and you're done

    Sorry I couldn't upload an image to show you I've just signed up.

    EDIT I now have enough reputation to upload the image:

    enter image description here