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?
3 Answers
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:
You could select the line your PHP command is on and do a Search and Replace operation with a regular expression. Search for
^(.*)$
and replace it with
<?php $1 ?>
as seen in the screen shot. The regular expression will match everything on the line and wrap the PHP tag around it.
-
-
That I don't know, I'm a BBEdit user myself :) I did download a TextMate demo to figure out that one.– KiezproSep 1, 2011 at 19:56
-
I was asking because sometimes Textmate is really really slow with regexes, and this looks like it might make it choke.– AgosSep 1, 2011 at 21:40
-
That's very possible. I'm kind of a Unix person, so my approach was a little Unix-ish. The other mentioned solutions are obviously better suited for this particular problem.– KiezproSep 2, 2011 at 21:10
The HTML bundle has a command to wrap in <?= ?>
:
You could assign a keyboard shortcut to this from the Bundle Editor, and if you're so inclined you could even add a new command for <?php ?>
.