Creating code snippets in Atom (macOS)

To add a code snippet to Atom, take the following steps:

Navigate to folder: /Users/galaktro/.atom

The .atom folder is hidden by default. Make sure to show all files and folders! The .atom folder contains a file called snippets.cson.

'.source.python':
  'clsEmployee':
    'prefix': 'clsEmployee'
    'body': """
class Employee:
    def __init__(self, name):
        self.name = name
"""

As you start typing, Atom offers your new snippet in the popup menu.

Hit enter et voila! There is your code:

class Employee:
    def __init__(self, name):
        self.name = name

Variables in snippets

Atom snippets allow you to insert variables if needed. They are defined with a dollar sign:

'clsEmployee2':
  'prefix': 'clsEmployee2'
  'body': """
class Employee:
  def __init__(self, $1):
      self.$1 = $1
"""