You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently snippets are defined by language type and only available when a file of that language is open. In an effort to not reproduce snippets between languages I'd like to see a "global" snippet .json file that makes snippets available for any file type, in addition to the file type specific ones defined in Code...Preferences...User Snippets.
Example. I've created a snippet for the CSS margin option:
Reacted by Fred Vatin, Brenton Simpson, Peter Matkovsky, Jonathan Stone, Sourav Barua, Max Sh, Vlad GURDIGA, Spencer Gardner, CAIHUAZHI, Alexander Holzinger and 2 more
With HTML / PHP this is particularly annoying since I would like to have my snippets working in the whole PHP file. Right now they work inside "normal" HTML parts, but not for example when I'm inside an attribute value:
e.g.
They work just fine inside html (when defined in html.json):
<div>They work inside this</div>
But they do not work inside an attribute:
<div class="image" style="background-image: url('SNIPPETS DOES NOT WORK HERE');">
I've tried adding my snippets to plaintext, xml etc, nothing seems to work inside attribute value.
I'm actually on the lookout for snippets being available on a workspace level in addition to the implementation as it is today. Here is why; Using Plaster it is easy to get the idea that snippets should be templated. However, when doing this via Plaster you avoid overwritting an potentially already existing "language".json file in the users "snippets" folder.
In regards to precedence I think the workspace snippets should have precedence. There is this other issue, here in the VS Code repo #8102 .... however still leaves with the fact that I have to control for a certain extension to be installed in VS Code. As of now that is not possible with Plaster.
Some more tweaks to the configure/creation picker. Now it groups things by existing snippets and allows to create new snippets (globally or per language)
I currently dev CFML and would love to be able to use HTML, CSS, CFML snippets all in the same .cfm file. I'd be good with the global.json solution proposed.
+1 for the comment issue. While programming, I need snippets mostly to comment same stuff consistently. And the feature is not working for comments for no reason :(
Activity
jrieken commentedon Oct 5, 2016
Makes sense. Needs thinking. Martin Aeschlimann (@aeschli) As the initial creator of this, ideas?
TheColorRed commentedon Oct 5, 2016
Couldn't you add something like this?
global.json
{ "My Awesome Snippet": { "prefix": "abc", "lang": ["css", "php", "html"], "body":[ "abc123!@#" ] } }TheColorRed commentedon Oct 5, 2016
Jason Reljac (@jreljac) That was just my example of implementation to answer Johannes Rieken (@jrieken) question.
[-]Global snippet option[/-][+][snippets] Global snippet option[/+]Ciantic commentedon Apr 18, 2017
With HTML / PHP this is particularly annoying since I would like to have my snippets working in the whole PHP file. Right now they work inside "normal" HTML parts, but not for example when I'm inside an attribute value:
e.g.
They work just fine inside html (when defined in html.json):
But they do not work inside an attribute:
I've tried adding my snippets to plaintext, xml etc, nothing seems to work inside attribute value.
nikpushkarski commentedon May 10, 2017
+1 for idea of common snippets for all/chosen languages
grigoryvp commentedon May 10, 2017
Will be very useful for both multi-language stacks like PHP and VueJS, and for commenting different code with comment-related language snippets
MunifTanjim commentedon Jun 2, 2017
For user-defined snippets, user/workspace setting could have something like this:
which will load all the user-defined "javascript" snippets in the "javascriptreact" files.
larssb commentedon Jun 27, 2017
I'm actually on the lookout for snippets being available on a workspace level in addition to the implementation as it is today. Here is why; Using Plaster it is easy to get the idea that snippets should be templated. However, when doing this via Plaster you avoid overwritting an potentially already existing "language".json file in the users "snippets" folder.
In regards to precedence I think the workspace snippets should have precedence. There is this other issue, here in the VS Code repo #8102 .... however still leaves with the fact that I have to control for a certain extension to be installed in VS Code. As of now that is not possible with Plaster.
All ideas are welcome. Thank you.
Fred-Vatin commentedon Aug 4, 2017
Currently, in last insider, there is no way AFAIK to have a common snippets file for CSS, LESS, SASS, etc. It is bulky. 😓
21 remaining items
allow code-snippets-files from extensions, #13182
fix grouping in config-snippet-picker, #13182
smarter SnippetFile#select, #13182
show global snippets atop, #13182
tweak snippet creation & customization #13182
jrieken commentedon Jan 5, 2018
Some more tweaks to the configure/creation picker. Now it groups things by existing snippets and allows to create new snippets (globally or per language)
pmolaro commentedon Jan 8, 2018
+1 for this
I currently dev CFML and would love to be able to use HTML, CSS, CFML snippets all in the same .cfm file. I'd be good with the global.json solution proposed.
fix an issue with fs events, #13182
nikpushkarski commentedon Jan 31, 2018
Thanks a lot for adding a new feature, but the global snippets still don't work inside both multiline and single line comments.
/*
don't work
*/
// don't work too
grigoryvp commentedon Jan 31, 2018
+1 for the comment issue. While programming, I need snippets mostly to comment same stuff consistently. And the feature is not working for comments for no reason :(