snippets
snippets copied to clipboard
Support multiple snippet prefixes
Sometimes you may want to have multiple prefixes for expanding the same snippet – currently, if you want to do that, you have to copy-paste a snippet and rename the prefix, which is unnecessary duplication if you just want to have two prefixes for the same snippet.
For example:
'.text.html':
'Div':
'prefix': ['div', 'd']
'body': '<div class="$2">\n\t$3\n</div>'
Instead of:
'.text.html':
'Div':
'prefix': 'div'
'body': '<div class="$2">\n\t$3\n</div>'
'Div (short)':
'prefix': 'd'
'body': '<div class="$2">\n\t$3\n</div>'
Seconded, this would be nice
Agreed, I just ran into this.
+1
+1
+1
Seems like a logical idea :)
+1
+1
+1
+1
+1
+1 This would be great
+1
Stop with the +1's please, just give the OP a thumbs up and if you want to subscribe to get notifications, just subscribe to the issue.
This seems like an incredibly useful idea. I just had the desire for exactly this and after a simple Google search found this issue. I can't believe it's been open since 2015 (over three years now)! What can we do to get the ball rolling on this feature?
My guess is that it's languished because the workaround is pretty simple, albeit verbose: just duplicate the snippet under a different prefix. So it's low-priority for the Atom maintainers, but nobody who really wants it to happen has opened a PR. I'm sure that PR would be accepted if it were made.
If it helps I just created copies for alt prefixes with very similar keys that are not identical, and instead of including the whole block i just alias back to the original prefix. It's an extra tab, but that's beats having mult copies of the code I think.
'Angular @Input get/set': 'prefix': 'setgetng' 'body': """ private ${1:var}: ${2:any}; @Input() set ${1:var}(val: ${3:any}) { //do stuff with val; this.${1:var} = val; } get ${1:var}() { return this._${1:var}; //or do stuff with _var } """ 'Angular @Input get set': 'prefix': 'getsetng' 'body': "setgetng" 'Angular @Input get-set': 'prefix': 'nggetset' 'body': "setgetng" 'Angular @Input get_set': 'prefix': 'ngsetget' 'body': "setgetng"
This is a nice feature that should be supported. 👍
@t0johnso Nice! I'd also add a hint on the aliases, like this:
'.source.coffee':
'CoffeeLint disable line':
'prefix': 'coffeelint-disable-line'
'body': '# coffeelint: disable-line='
'CoffeeLint disable line (alias)':
'prefix': 'clintl'
'body': 'coffeelint-disable-line'