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__': 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.’
'.text.md': 'Image': 'prefix': 'img' 'body': '![$1](/images/$2 "$3")'
- Snippet Name
- Text to trigger the snippet
- 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:
[^1] Scope. Find the scope with the hotkeys control + shift + P then type scope. Use the first listing.
Optional Parameters for Snippets: Style the type hint panel with CSS to add color highlights or custom text.