snippets icon indicating copy to clipboard operation
snippets copied to clipboard

Support multiple snippet prefixes

Open mnquintana opened this issue 10 years ago • 19 comments

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>'

mnquintana avatar Feb 06 '15 02:02 mnquintana

Seconded, this would be nice

CopperBadger avatar Feb 22 '15 00:02 CopperBadger

Agreed, I just ran into this.

bronson avatar Jan 09 '16 20:01 bronson

+1

gusaiani avatar Jan 27 '16 11:01 gusaiani

+1

prozion avatar Jan 01 '17 12:01 prozion

+1

acevif avatar Feb 02 '17 03:02 acevif

Seems like a logical idea :)

mikeerickson avatar Feb 02 '17 03:02 mikeerickson

+1

mythical-programmer avatar Feb 06 '17 02:02 mythical-programmer

+1

globaljake avatar Mar 15 '17 14:03 globaljake

+1

JohanG2012 avatar Jun 02 '17 23:06 JohanG2012

+1

dtgoitia avatar Jun 29 '17 12:06 dtgoitia

+1

Askerad avatar Jul 27 '17 12:07 Askerad

+1 This would be great

ChippyWhips avatar Feb 08 '18 21:02 ChippyWhips

+1

jkupczak avatar Mar 07 '18 19:03 jkupczak

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.

darrenterhune avatar Mar 07 '18 20:03 darrenterhune

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?

PHLAK avatar Mar 16 '18 21:03 PHLAK

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.

savetheclocktower avatar Mar 16 '18 21:03 savetheclocktower

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"

t0johnso avatar Jun 19 '18 17:06 t0johnso

This is a nice feature that should be supported. 👍

aminya avatar Dec 29 '19 20:12 aminya

@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'

wjandrea avatar Jan 12 '22 20:01 wjandrea