Snippets not working


#1

Hi, I made a few snippets and none of them work. Worst of all, the default snippet from hitting snip, doesn’t even work. This is in snippets.cson:

Your snippets

#…

‘.source.js’:
‘hello’:
‘prefix’: ‘hello’
‘body’: ‘Hello World!’

‘*’:
‘django model’:
‘prefix’: ‘djmod’
‘body’: “”“
class (models.Model):
x = models.CharField(max_length=256)
”""

the tabs aren’t showing up here, but I have tabs set to 4 spaces and even the original snip snippet won’t work

**I had to convert spaces to tabs in this file, now I am trying to figure out how to deal with python tabs. Thank you


#2

CSON works much like JSON in that it is an object notation and when you redefine a key, it overwrites any previous value. So if you have this:

'.text.html':
  'Image PlaceHolder':
    'prefix': 'nnplaceholder'
    'body': '<img src="http://placehold.it/500x200">'
'.text.html':
  'Some other snippet':
    'prefix': 'something'
    'body': 'somestuff'

The only snippet you’ll see is “Some other snippet”. This is the most common reason why snippets appear to not be working for people.


#4

I still cant get this to work consistently for me.

Inside of .text.html I have

  'Nucleo Outline Font Class':
    'prefix': 'nio'
    'body': 'nucleo-icon-outline'

I switch to my html document, type nio always get <nio></nio>. What gives?

I’ve tried to use .text.html and text.html.angular but neither works.


#5

This sounds exactly like the symptoms described in this other topic:

Which seems to be caused by the emmet package.


#6

Makes sense.

So, if anyone is interested, I simply defined my snippets in Emmet instead of Atom. This also means I’ll have them if I need to use any Emmet-compatible IDE.

In ~/emmet/snippets.json I have

"html": {
		"filters": "html",
		"profile": "html",
		"snippets": {
			"!!!": "<!DOCTYPE html>",
                        "nio": "nc-icon-outline"
		},
		"abbreviations": {
			"!": "html:5"	
		}
	},

See http://docs.emmet.io/customization/snippets/ for more info.