Reputation: 143
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.
Upvotes: 7
Views: 17817
Reputation: 151
Use:
Open Visual Studio Code
Open menu File → Preferences → User Snippets
Search and select "html.json"
Now paste this code in {}:
"php": {
"prefix": ["<?", "<? ", "php"],
"body": [ "<?php $1 ?>" ],
"description": "php tag"
}
Now you can use "<?"
or "<? "
or "php"
.
Upvotes: 15
Reputation: 354
I have used this in order to quickly order the space.
"php": {
"prefix": ["<?", "php"],
"body": [
"<?php",
"",
"$0",
"",
"?>"
],
"description": "php tag"
}
You get something like this:
<?php
(code here)
?>
Upvotes: 1
Reputation: 1989
You can add a custom user snippet to Visual Studio Code:
Paste the following custom snippet:
"php": {
"prefix": "php",
"body": [ "<?php $1 ?>" ],
"description": "php tag"
}
Upvotes: 35