atom / snippets

Atom snippets package
MIT License
205 stars 100 forks source link

Sass snippet #175

Closed jiayihu closed 8 years ago

jiayihu commented 8 years ago

I read the documentation but I can't make my snippet work, whereas the examples are okay. Hope you can help me understand my mistake. Here is the snippet:

'.source.sass':
  'section comment':
    'prefix': '/* ='
    'body': """
      /* ==========================================================================
         ${1:"Section comment"}
         ========================================================================== */
    """
benogle commented 8 years ago

What else is in your snippets file? Can you paste in the entire thing? Does it work without the space in the prefix?

jiayihu commented 8 years ago

Nope, it doesn't work. The snippet file is the default one:

# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
# '.source.coffee':
#   'Console log':
#     'prefix': 'log'
#     'body': 'console.log $1'
#
# This file uses CoffeeScript Object Notation (CSON).
# If you are unfamiliar with CSON, you can read more about it here:
# https://github.com/bevry/cson#what-is-cson

'.source.sass':
  'section comment':
    'prefix': '/*='
    'body': """
      /* ==========================================================================
         ${1:"Section comment"}
         ========================================================================== */
    """

# This example works
'.source.js':
  'if, else if, else':
    'prefix': 'ieie'
    'body': """
      if (${1:true}) {
        $2
      } else if (${3:false}) {
        $4
      } else {
        $5
      }
    """

EDIT: seems that the problem is with the prefix '/*=' because it works now that I have changed it with 'comment-block'

benogle commented 8 years ago

It works for me without the space. So /*= works fine for me. But with the space it doesnt. It finds the prefix by looking backward for a word break, so it finds = as the prefix when there is a space.

Closing this as a wont fix, as supporting spaces in the prefixes is complex and unnecessary.