Reputation: 66
In TextMate one could type php<tab>
to insert <?php | ?>
(with the | here marking cursor position).
I'm trying to recreate it in VSC like this in the php.json snippets file:
"php tag": {
"prefix": "php",
"body": [
"<?php $1 ?>"
],
"description": "Insert <?php ?>"
}
The problem is that the snippet doesn't show up unless I'm already inside php tags, which kind of defeats the purpose.
Adding the snippet to the HTML file instead does not help.
Is there any way I can make this work the way I want to?
Upvotes: 4
Views: 11683
Reputation: 81
Go to file > preferences > user snippet
then select New Global Snippets file
and you are asked to save the .code-snippets
extension file for the name of the file is free up to you and enter your snippet configuration, for example:
"php tag": {
"prefix": "php",
"body": [
"<? php $1 ?>"
],
"description": "Insert <?php ?>"
}
And save your file
Upvotes: 8
Reputation: 51
try adding this to global.code-snippets
"PHP tag": {
"scope": "",
"prefix": "php",
"body": [
"<?php $1 ?>"
],
"description": "Insert php tags"
}
Upvotes: 5