Skip to content

Instantly share code, notes, and snippets.

@dvingo
Last active January 7, 2018 16:36
Show Gist options
  • Save dvingo/b930822e855581a9ad09626a10a747ac to your computer and use it in GitHub Desktop.
Save dvingo/b930822e855581a9ad09626a10a747ac to your computer and use it in GitHub Desktop.
Atom Editor: snippets
#
# How to write atom snippets.
#
# Docs:
# https://atom.io/packages/snippets
#
# Find your source file name key that atom uses:
#
#
# 1. Put your cursor in a file in which you want the snippet to be available.
#
# 2. Open the Command Palette (cmd + shift + p), and run the Editor: Log Cursor Scope command.
#
# 3. This will trigger a notification which will contain a list of scopes.
# The first scope that's listed is the scope for that language.
# Here are some examples: source.coffee, text.plain, text.html.basic.
#
# # GNU/Linux
# Edit > Open Your Snippets menu option
#
# # Windows
# File > Open Your Snippets menu option
#
# # OSX
# Atom > Snippets...
#
# Snippets files are stored in a package's `snippets/` folder and also loaded from `~/.atom/snippets.cson`
'.source.js':
'if, else if, else':
'prefix': 'ieie'
'body': """
if (${1:true}) {
$2
} else if (${3:false}) {
$4
} else {
$5
}
"""
# Including a literal closing brace inside the text provided by a snippet's
# tab stop will close that tab stop early. To prevent that, escape the brace
# with two backslashes, like so:
'.source.js':
'function':
'prefix': 'funct'
'body': """
${1:function () {
statements;
\\}
this line is also included in the snippet tab;
}
"""
# When you write your actual snippets file you need to put the
# snippets for the same scope under one key:
# Snippets for the same scope must be placed within the same key.
# See this section of the Atom Flight Manual for more information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment