Annabel
Annabel

Reputation: 1414

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

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?

Upvotes: 10

Views: 7337

Answers (5)

wgcorrea
wgcorrea

Reputation: 1

Just type php + TAB to have <?php ?> or phpe + TAB for <?php echo ?>

It's works for Netbeans 8 with default Php Package

If you want, you can change that shortcut on Tools -> Options -> Editor -> Code Templates; choose HTML on Language's select box.

Upvotes: 0

Annabel
Annabel

Reputation: 1414

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.

Upvotes: 16

KahWee Teng
KahWee Teng

Reputation: 14188

There isn't one by default. The closest is typing <? and pressing ctrl+space which will suggest you <?php...

Upvotes: 0

Menztrual
Menztrual

Reputation: 41607

I don't think there is, but you can create a macro to do it yourself :)

You just have to click on Edit -> Start Macro Recording then you have to type in <?php ?> and afterwards click on Edit -> Stop Macro Recording.

Upvotes: 1

Ray
Ray

Reputation: 884

Looked through the guide and didn't see any

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

Upvotes: 1

Related Questions