My first snippet doesn't work :-(


#1

I tried making a snippet but it doesn’t work. :frowning:

'.text.html.basic':
  'HTML5 Skeleton':
    'prefix': 'html5'
    'body': """
    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" href="styles.css">
        <title>Title</title>
      </head>
      <body>

      </body>
    </html>
    """

The html snippet isn’t complete, IMHO. :slight_smile: When I create a new .html file and type in html5 and TAB nothing happens. Any ideas what the problem is?

And please tell me if this snippet already exists! I tried installing the package autocomplete-html but it made Atom crash every minute or two. I had to uninstall Atom from the terminal and do a fresh install.


#2

It has to be properly formatted (with tabs).
This one works for me:

'.text.html.basic':
  'HTML5 Skeleton':
    'prefix': 'html5'
    'body': "foo"

When you open your snippets.cson, type snip and press tab you get a nice snippet placeholder.

See also: http://pipetree.com/qmacro/blog/2015/01/atom-snippets-tabs-and-cson-parsing/


#3

It works perfectly. Apparently I had to shut down Atom and restart it for the snippet to start working.

And I don’t know why my snippet didn’t display properly in my post! Ask me if you want the snippet, it’s like the html snippet but adds the doctype, charset, a link to a stylesheet. etc.


#4

I went ahead and fixed the original post. The board supports fenced code blocks as in GitHub-Flavored Markdown.


#5

Thanks! I’ll look into the fenced code blocks.