Code Macros in Atom Editor - Snippets

Ever notice in Atom Editor that when you start typing common code constructions, it tries to auto-complete the rest of the block. For instance in Python if you start typing ‘ifmain’ it completes with:

if __name__ == '__main__':

The if main check is a frequently used construction, so Atom has it as a built-in Macro or Snippet.

Unfortunately, Atom does not have very many standard snippets for Markdown, but it is easy to add your own.
To add a snippet to insert an image into Markdown:

From the edit menu, select ‘Snippets.’

Atom Editor - Edit Menu with Snippet Selected

    'prefix': 'img'
    'body': '![$1](/images/$2 "$3")'
  1. Scope[^1]
  2. Snippet Name
  3. Text to trigger the snippet
  4. The content of the snippet, for multiline code blocks use triple quotes.
    • Note the $1, $2 and $3, set your tab order to populate the code block.

Here are some more I have found handy for Markdown.

Insert the Front Matter block for Jekyll:


  'Post Front Matter':
    'prefix': 'post'
    'body': """

                    layout: post
                    title: $1



[^1] Scope. Find the scope with the hotkeys control + shift + P then type scope. Use the first listing.

Additional Reading

Atom Documentation - Snippets

Optional Parameters for Snippets: Style the type hint panel with CSS to add color highlights or custom text.

Written on January 22, 2018