Snippet with multiple sources


#1

How do you define .source.php with multiple types. Say i want to be able to use this snippet in both .php and .scssfiles.

'.source.php':
  'One line comment':
    'prefix': 'comm'
    'body': '/***********  ${1:Subsection comment block}  ***********/`

Bonus question:
If i add another snippet below this one in snippets.cson this one stops working. Do i separate snippet in some way?


#2

I don’t know this, but have you tried standard CSS comma separation? Atom kinda uses CSS-like syntax but I’m not sure exactly where the similarities end. But yeah, try '.source.php, .source.scss' as your ‘selector’. I doubt it’ll work though.

As for your bonus question, I don’t know why that wouldn’t work (other than indentation but presumably you’ve triple-checked that) but the code you pasted here ends in a backtick (``` ``) rather than a single quote. That may be a copy-pase error or it may be the source of your issue.


#3

I had this problem too. Turns out you need to make sure not to repeat the scope line multiple times. For example:

'.source.php':
  'One line comment':
    'prefix': 'comm'
    'body': '/***********  ${1:Subsection comment block}  ***********/'

  'Something Else':
    'prefix': 'prefix-yo!'
    'body': 'thingsAndStuff'

Just don’t repeat 'source.php': for each snippet.

The snippets themselves don’t need any delimiter. I used three blank lines just for readability’s sake.


#4

@alexrussell is right, use comma separated selectors:

'.source.php, .source.scss':
  'One line comment':
    'prefix': 'comm'
    'body': '/***********  ${1:Subsection comment block}  ***********/`

I’m not sure why the snippet breaks after adding one below, I would have to see both together to get a better idea. Take a look at language-todo snippets for an example.

Edit. fixed source formatting, I hope.


#5

I see the backtick now (at the end of the body line) that is probably it.