0
Good afternoon. I looked here (/search?q=%5Batom%5D+Snippets), but I couldn’t get help, so I decided to read this post.
I currently use phpStorm, but it is very heavy, so I will start testing the Atom.
I’m having a hard time recreating my Snippets that were on phpStorm and recreating on snippets.cson
. Always appears Duplicate key.
How to create multiple Snippets in 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>";
"""
VERSION 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>
"""
Hi Anderson, thanks for the help. Html snipts are not working, see image http://prntscr.com/nyi3sp
– Tiago
@James and the image makes clear the problem: indentation
– Woss
What do you mean? How should it look?
– Tiago
The same way I put it in the answer
– Woss
I copied and pasted in my file, just added one more Html5 call.
– Tiago
I updated my code by putting VERSION 2, please, for a look.
– Tiago
@Tiago See that snippet
html5
is indented from the previous snippet. Just remove this indentation level. It should only be indented with 2 spaces, it has 4 spaces. In the cited documentation there are more details about the syntax used if you need.– Woss
I think I’m too dumb... It may be very clear to you, but I can’t see my failure :(
– Tiago
You know what indentation is?
– Woss
snip (http://prntscr.com/nyiaay). Using (http://prntscr.com/nyiajy) the Html5 I created not being recognized.
– Tiago
Let’s go continue this discussion in chat.
– Woss