Creating the Snippet itself in the Atom

Asked

Viewed 999 times

2

I’m trying to create my own snippets on Atom, but none of them work at all.

tried:

'*':
  'Controller text'
    'prefix': 'lco'
    'body': 'my name is $1'

but when typing lco and press TAB, does nothing, also tried for php

'.source.php':
  'Controller text'
    'prefix': 'lco'
    'body': 'my name is $1'

and for html

'.source.html':
  'Controller text'
    'prefix': 'lco'
    'body': 'my name is $1'

or

'.text.html':
  'Controller text'
    'prefix': 'lco'
    'body': 'my name is $1'

In none of the ways I create my personal snippets Atom creates the snippets. In the above cases are examples to simplify what I wish to do.

What is the right way to work with snippets in Atom? I’ve followed examples of the documentation and can’t get the expected results.

Att. Thiago Prado

3 answers

4


We’re missing a : after the name of the snippet:

'.source.php':
  'Controller text':  # Aqui.
    'prefix': 'lco'
    'body': 'my name is $1'
  • Thank you, really a very silly mistake on my part! But I didn’t notice in any way, even looking at the examples, bad part of not having a Bugger.

  • 1

    You can access Development Tools from the View > Developer menu. That’s how I found out what was wrong.

  • Taking advantage would know how to appear the options of a placehold area? I’m trying: '.source.php':
 'laravel route':
 'prefix': 'route'
 'body': 'Route::${1|get,post,resource,any,matched,pattern,filter|}(\'${2:/}\', ${3:function(){\n
 \t${4:...};
 \n}});' But not right, and has no information on how to do it correctly by coffeescript. And also does not generate error.

2

In this new version it just wasn’t working.

To work I had to do the following (for any language) without variables.

'*':
  'Snippet Name':
    'prefix': 'html'
    'body': """
      <!DOCTYPE HTML>
      <html lang="pt-br">
          <head>
          $1
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
          <link rel="icon" href="favicon.ico" type="image/x-icon" />
          <link rel="stylesheet" type="text/css" href="css/estilo.css">
          <script type="text/javascript" src="js/arquivoJS.js"></script>
          <title></title>
          </head>
          <body>
            <h1>CONTEUDO</h1>
          </body>
      </html>
    """

0

Follow an example, I just don’t know how to add the icons f: function, c: class etc...

'.source.php':
    'Function isset':
        'leftLabel': 'bool'
        'prefix': 'isset($var)'
        'rightLabelHTML': 'Informa se a variável foi iniciada'
        'body': 'isset(${1:$var})$2'
        'description': 'Documentação php.net'
        'descriptionMoreURL': 'https://www.php.net/manual/en/function.isset.php'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.