0

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>
      """

1 Resposta 1

0

Como especificado na documentação, basta você definir o source apenas uma vez:

################################################
#        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'];
    """

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

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

  'Snippet Name':
    'prefix': 'Snippet Trigger'
    'body': """
    echo "<script>alert('Mensagem');</script>";
    """
11
  • Olá Anderson, obrigado pela ajuda. Os snipts de html não estão funcionando, vejam a imagem prntscr.com/nyi3sp
    – Tiago
    Commented 6/06/2019 às 17:17
  • @Tiago e pela imagem fica claro o problema: indentação
    – Woss
    Commented 6/06/2019 às 17:18
  • Como assim? Como deve ficar?
    – Tiago
    Commented 6/06/2019 às 17:20
  • Da mesma forma que eu coloquei na resposta
    – Woss
    Commented 6/06/2019 às 17:21
  • Eu copiei e colei no meu arquivo, só adicionei mais uma chamada html5.
    – Tiago
    Commented 6/06/2019 às 17:22

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .