'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.
Solution 1:[1]
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" }
Solution 2:[2]
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"
.
Solution 3:[3]
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)
?>
Solution 4:[4]
Use extension "Sublime Text Keymap for VS Code".
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Ãlvaro González |
Solution 2 | Peter Mortensen |
Solution 3 | Reichlich |
Solution 4 | Peter Mortensen |