Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP in Netbeans: Is there shortcut to generate the <?php ?> tags

Tags:

php

netbeans

I've just started using Netbeans (7.1.2, php version) to work on a PHP project. Netbeans is really great for editing long stretches of PHP Code.

But in my view files where HTML is mixed up with short bits of PHP I am getting really tired of manually typing:

<?php  ?>

In Dreamweaver you just press a button to create these tags, but in Netbeans I can't find anything like a keyboard shortcut. Surely there must be one. Does anybody know what it is?

like image 648
Annabel Avatar asked May 21 '12 01:05

Annabel


2 Answers

In Netbeans I had gone to Tools -> Options -> Editor -> Code Templates and looked through all abbreviations for the PHP language. There were lots and lots of abbreviations for pieces of PHP. But the <?php ?> tags weren't there.

After typing out my question it occurred to me that the place such abbreviations would be was for the HTML language instead of PHP. I looked there and there weren't any code templates at all. But it was simple to add one of my own (abbreviation: 'p', expanded text '<?php ?>').

Now when the cursor's in the middle of some HTML, I type p[TAB] and my tags appear!

Update
Thanks to link from @chris in comment above I can change expanded text to <?php echo ${cursor} ?> and the cursor ends up where I want it.

like image 147
Annabel Avatar answered Oct 24 '22 06:10

Annabel


Looked through the guide and didn't see any

http://netbeans.org/project_downloads/www/shortcuts.pdf

like image 1
Ray Avatar answered Oct 24 '22 05:10

Ray