Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP block shortcut in Visual Studio Code

How can I open a basic PHP block in Visual Studio Code, like so - <?php ?>?

In Sublime Text I simply type php and press Tab, and the block is created. But I can't find the same shortcut for Visual Studio Code.

like image 820
Alexander Avatar asked Jul 08 '26 16:07

Alexander


2 Answers

You can add a custom user snippet to Visual Studio Code:

  • Open "Preferences"
  • User Snippets
  • Select html.json (HTML)
  • Paste the following custom snippet:

    "php": {
        "prefix": "php",
        "body": [ "<?php $1 ?>" ],
        "description": "php tag"
    }
    
like image 153
benedikt Avatar answered Jul 13 '26 07:07

benedikt


Use:

  1. Open Visual Studio Code

  2. Open menu FilePreferencesUser Snippets

  3. Search and select "html.json"

  4. Now paste this code in {}:

     "php": {
         "prefix": ["<?", "<? ", "php"],
         "body": [ "<?php $1 ?>" ],
         "description": "php tag"
     }
    

Now you can use "<?" or "<? " or "php".

like image 22
AlNisr Avatar answered Jul 13 '26 06:07

AlNisr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!