Creating Code shortcuts


I am completely unfamiliar with how to code the keybinds in the atom environment. I am trying to create a shortcut for a few different lines of code. For example #### :bulb: KNOWLEDGE which I use quite frequently, I would rather just use a key combination or quick “bulb” to input. There are many others I need, but I presume once I get the gist of creating one shortcut I can figure out the others.

I am pretty sure what I’m looking for is Snippets, but I’m not entirely sure the format for writing them to make a universal snippet (not designated to an individual file).



I attempted using the following snippet:

'.source.gfm' 'Knowledge' 'prefix': 'Bulb' 'body': '#### :bulb: KNOWLEDGE'

And when saving snippets.cson receive the following error:

Failed to load snippets from 'C:\Users\<me>.atom\snippets.cson' C:\Users\<me>\.atom\snippets.cson: unexpected indentation

And if I type “bulb” into the editor it doesn’t return any additional options.


You need to have the snippet indented like in the examples:

    'prefix': 'Bulb'
    'body': '#### :bulb: KNOWLEDGE'



Sorry, it didn’t translate well when I copied it and I forgot edit it. But I tried with both indents and with spaces (0 on the source, 1 on the title, and 2 on the keys).

Ahhh! I just got it… I was missing the : after the source and title. Works perfect now. We can go ahead and close er out.


Okay new problem… I tried adding a commented out description in the same line as the source, i.e:

‘.source.gfm’ <–Knowledge–>
‘prefix’: ‘Bulb’
‘body’: ‘#### :bulb: KNOWLEDGE’

so that I could condense all of the snippets and still know what’s what. I received an error when saving due to this. So I took the comment out, changed it to “# knowledge” on the line above the snippet, matching the format on the top of the snippets.cson files. This saved with no error, I went back to my editor and typed “Bulb” with no results. Removed the # line, still no results on bulb. Not sure how I get this working, none of my snippets are now working even after closing and reopening atom.

Also, not sure why I didn’t think of this in the first place… All of my snippets are using the same source, but I have a separate block for each of them… Can I just condense all of them under the topmost source, only adding new titles, and then use the title to minimize them while keeping the source expanded?

Apologies, as I mentioned earlier, new to this side of it…


What do you mean by “condense”? I don’t think that CSON does comments.

All of my snippets are using the same source, but I have a separate block for each of them… Can I just condense all of them under the topmost source

If you read down in the Flight Manual, you will find that that is exactly how you’re supposed to add multiple snippets for the same grammar. One of the reasons why your snippets aren’t working is probably the fact that you have multiple keys with the same name. When Atom goes to fetch snippets for .source.gfm, it’s going to grab one of those and ignore all the others.


Awesome! Tiering it took care of the issues. Thanks again!