Snippets: Why does only the last snippet work?


#1

Why in this snippet file is it only the last one, the Dashed Comment Block, that works?

'.source.js':
  'Normal Comment Block':
    'prefix': 'cmm'
    'body': """
      //**********************************************************************************
      //
      //**********************************************************************************
    """

'.source.js':
  'Dashed Comment Block':
    'prefix': 'c--'
    'body': """
      //----------------------------------------------------------------------------------
      //
      //----------------------------------------------------------------------------------
    """

The configuration file format for snippets (among other things in Atom) is called CSON, CoffeeScript Object Notation. Like JSON (JavaScript Object Notation) it is a text format for describing simple objects. Because of which, when you specify a key twice, like .source.js in the example, the second instance overwrites the first. If you simply have one .source.js everything will work fine:

'.source.js':
  'Normal Comment Block':
    'prefix': 'cmm'
    'body': """
      //**********************************************************************************
      // $1
      //**********************************************************************************
      $0
    """
  'Dashed Comment Block':
    'prefix': 'c--'
    'body': """
      //----------------------------------------------------------------------------------
      // $1
      //----------------------------------------------------------------------------------
      $0
     """

Additionally, I added tab stops to the example so that when you expand the snippet, your cursor should land first inside the comment. You can enter your comment and then press TAB to exit out and continue on.


Why are some snippets not working?
Why are some of custom keybindings resolved while other are not?
How to create Key Binding for inserting text in editor
Oddity in PHP Snippets
Can only make one snippet on python :/
Where's the `language-c` core package actually installed?
Are multiple identical selectors in a keymap valid?
Only taking the last configuration at keymap.cson