Skip to main content
4 de 4
tags editadas
Tiago
  • 2,4mil
  • 5
  • 29
  • 62

Criando vários Snippets

Boa tarde. Procurei aqui (https://pt.stackoverflow.com/search?q=%5Batom%5D+Snippets), mas não consegui ajuda, por isso resolvi abir esse post.

Atualmente uso o phpStorm, mas ele é muito pesado, por isso vou começar a testar o Atom.

Estou tendo dificuldades em recriar meus Snippets que estavam no phpStorm e recriar no snippets.cson. Sempre aparece Duplicate key.

Como é a forma correta de criar vários Snippets no Atom?

################################################
#        JS
################################################
'.source.js':
   'Console log':
     'prefix': 'log'
     'body': 'console.log $1'

'.source.js':
  '$("#").val()':
    'prefix': '$'
    'body': '$("#").val()'

################################################
#        PHP
################################################
'.source.php':
  'Select':
    'prefix': 'select'
    'body': """
        $rs = $mysqli->query("SELECT * FROM tabela WHERE coluna = '".$_GET['id']."' ");
        $row_rs = $rs->fetch_assoc();
        $rowTotal = $rs->num_rows;
        echo $row_rs['nome'];
    """

################################################
#        HTML
################################################

'.source.html':
  'Controller text':
    'prefix': '?'
    'body': '<?= $resultado["###"]; ?>'

'.source.html':
  'Snippet Name':
    'prefix': 'Snippet Trigger'
    'body': """
    echo "<script>alert('Mensagem');</script>";
    """

VERSÃO 2

################################################
#        JS
################################################
'.source.js':
   'Console log':
     'prefix': 'log'
     'body': 'console.log $1'

  '$("#").val()':
    'prefix': '$'
    'body': '$("#").val()'

################################################
#        PHP
################################################
'.source.php':
  'Select':
    'prefix': 'select'
    'body': """
        $rs = $mysqli->query("SELECT * FROM tabela WHERE coluna = '".$_GET['id']."' ");
        $row_rs = $rs->fetch_assoc();
        $rowTotal = $rs->num_rows;
        echo $row_rs['nome'];
    """

  'Alert':
    'prefix': 'alert'
    'body': """echo "<script>alert('Mensagem');</script>";"""

################################################
#        HTML
################################################

'.source.html':
  'echo':
    'prefix': '?'
    'body': '<?= $resultado["###"]; ?>'


    'html5':
      'prefix': 'html5'
      'body': """
        <!DOCTYPE html>
        <html lang="pt-br">
        <head>
            <meta charset="utf-8"/>
            <title></title>

            <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        </head>
        <body>




        </body>
        </html>
      """
Tiago
  • 2,4mil
  • 5
  • 29
  • 62