Posted on Thursday, 21st August 2008 by Lee
When using TextMate to code PHP, you may be annoyed by the way TextMate handles hitting the Enter key while in a PHP comment block. I would like the lead * to be continued on the new line. There are two ways to get this to happen.
The Easy Way
Intead of hitting the Return key on your keyboard, hit the Enter key on the number pad. The new line that gets created will have the leading * and you can continue your comment. If you are on a laptop, hit function Return since you may not have a number pad.
The Slightly Harder Way
If you don’t want to fling your hand all the way over to your number pad and would prefer to just hit the normal Return key to continue your comment, you can create a TextMate Snippet to get TextMate to enter the leading * on the new line.
- Open the Bundle Editor
- Create a new Snippet
- Name the Snippet something like “phpdoc newline”
- Clear the default snippet text and enter this regular expression
${TM_CURRENT_LINE/(.*/$)|.?(/*(?!.*/)).|./(?1: : (?2: ) )/}
- Set Activation: Key Equivalent
- Click in the Activation text box and press your Return key
- Set Scope Selector: source.php comment.block
Thank you to Clay Loveless for blogging about this Snippet
Posted in CodeIgniter, Mac OSX, PHP, Web Development | Comments (0)










