How do you configure/use snippets?


I couldn’t find any documentation on how to use snippets on the site.

This is what I wrote in my snippets.cson file:

  'HTML5 Skeleton':
    'prefix': 'html5skel'
    'body': '<!doctype html>'

saved it, quit atom, then opened a new test.html file, typed “html5skel” then hit tab and nothing showed up, I just added up tabbing 2 spaces, lol.

Can someone explain to me how to use the snippets feature?

Website Templating


I can’t see why it isn’t working though.

Edit: Try removing quotes from 'prefix' and 'body' key names.


I followed similar syntax to @bricejlin and also couldn’t get it to work. It just added two spaces.


I tried removing the quotes but it didn’t help.

It’s kinda confusing because the comments shows a different syntax using quotes.

# An example CoffeeScript snippet to expand log to console.log:
# '':
#   'Console log':
#     'prefix': 'log'
#     'body': 'console.log $1'


Snippets for CSS and JS work, but not for HTML and PHP. Here my PHP snippet:

  'Formatted var_dump':
    'prefix': 'test'
    'body': 'This is a test.'


I’ve gotten it to work.

Instead of:

  'HTML5 Skeleton':
    'prefix': 'html5skel'
    'body': '<!doctype html>'


'.text.html': <--
    'HTML5 Skeleton':
      'prefix': 'html5skel'
      'body': '<!doctype html>'

Its not working well with the ‘source’ name, but ‘text’ works . . .mostly. I’ve noticed some differences when including non-alpha/numeric characters too.


I’m not having any luck using the included Ruby on Rails snippets either. I opened app/models/something.rb and added:

class Something < ActiveRecord::Base

Which just resulted in a tab, not after_create like I hoped.


Do I need a “snippet configuration” for this? I’m just trying to do what it says in the documentation in the settings for atom/language-ruby-on-rails… Potentially that stuff just isn’t working yet?


Here an example of my working snippets for HTML, CSS, JS and PHP.


@jsanders Here ya go


Oh man, I should have known this. I rarely use HTML so it must have slipped my mind that it uses the text scope.

I can’t see why Php is using text.php though.


@jsanders: I think you’re referring to the grammer ‘Ruby on Rails’ snippets correct? You need to verify that the file’s grammer is set to that and not ‘Ruby’ (ctrl-shift-l, i think…)


What would the syntax for a generic snippet look like? One that could be applied to any document?

I tried starting the snippet with '.*' but that didn’t seem to work.


Probably .text, .source covers everything.


Any idea what I should use for Markdown snippets. Tried all suggest but nothing was working.


Markdown (in Sublime Text) has the text.html.markdown base scope.


Had no luck with that either.


Any luck with ERB files ? Got frustrated when trying to do a simple snippet. If is not possible to aim ERB specifically, at least a generic way to add snippets to all kind of extensions would be good.


in my snippets.cson, i want to require a folder named javascript and has a file named console.cson. you could see the structure below:

    -- console.cson

Now, in my snippets.cson, i want to include the console.cson to use the snippet I defined in there, What should I do?

I tried with

require './javascript/console.cson'

it output the error

Error reading snippets file '/Users/mma/.atom/snippets.cson': ReferenceError: require is not defined

I figure that it is not a node javascript file, so require is not available in the scope.

Is there a better way that I could lazy load all files inside javascript folder? I could just create new snippet in there, it just reload in atom editor and ready to be used? Thanks in advance!


I managed to get a couple of ERB snippets to work with the following:

  'end tag':
    'prefix': 'end'
    'body': '<% end %> $1'

.text.html.erb worked too.