Reputation: 1044
I've been trying to solve this for weeks but I finally gave up and decided to ask for help..
I wrote a lot of snippets for my web projects (HTML, PHP, JS, VUE, Laravel Blade, etc.) and I created several Global .code-snippet files and they show up in every project or file I open in VSCode, this is not a desired behavior and I'll explain you why.
When I open C++ Projects I don't want the editor to prompt me HTML stuff or Bootstrap icons, I made specific C++ scripts (and added .h extension to the C++ language mode, otherwise they would only work with files with .cpp extension), unfortunately I can't do the same thing with the languages I mentioned before because they're really different languages.
In my \AppData\Roaming\Code\User\snippets
folder I can see there are two types of files, my custom snippets have .code-snippets extension, language specific snippets have .json extension (example cpp.json
), syntax is the same.
I could create a copy of custom.code-snippets
for every file extension and pair it to every language I need (For example html.json
, php.json
, blade.json
, etc.) but this looks really stupid to me because If I want to add a snippet I would have to add it to every file manually.
Thank you in advance,
Upvotes: 4
Views: 1840
Reputation: 1044
The best solution I found is using "scope" for single snippets, but I'm not really satisfied with it:
"Bootstrap Icons Alarm Fill": {
"prefix": ["bsi-alarm","bsi-clock"],
"body": "<i class='bsi bi-alarm'></i>",
"description": "Bootstrap Icons Alarm Fill"
},
I can add to every snippet: "scope":"html,php,blade,vue,javascript,xml",
to make it show only with specified file extensions, but I'll have to add it to every snippet (Imagine that only in this file I have more than 1200 snippets, I can easily do it but I'd prefer not to), I'd like to make the entire file specific to several extensions.
Upvotes: 7