我的 snippets.cson 中只有前两个代码片段适用于 Atom
Only first two code snippets in my snippets.cson work in Atom
我想在 Atom 中使用我自己的代码片段,但经过几个小时的尝试,我仍然无法使用超过前两个代码片段,而且我找不到错误。
当我寻找解决方案时,我发现了很多很多主题,但每个主题中的错误都是重复使用源范围,但这不是我的问题。实际上,我几乎尝试了所有方法,对语法做了很多更改,但没有任何帮助。
".text.html.basic, .text.html.php":
"Include jQuery":
"prefix": "jquery"
"body": "<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>"
"Basic HTML structure":
"prefix": "start"
"body": '''
<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="author" content="MagicDev">
<meta name="keywords" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
<script src="script.js"></script>
<title></title>
</head>
<body>
</body>
</html>
'''
"DB Connection":
"prefix": "connection"
"body": '''
<?php
$servername = "";
$username = "";
$password = "";
$dbname = "";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
mysqli_query($conn, "set names utf8");
?>
'''
"DB Close Connection":
"prefix": "disconnection"
"body": "$conn->close();"
"DB Insert":
"prefix": "insert"
"body": '''
$sql = $conn->prepare("INSERT INTO ${1:"table"} (${2:"attributes"})
VALUES (${3:"?,?,?"})");
$sql->bind_param("${4:"ssi"}", ${5:"variablesToInsert"});
$sql->execute();
$sql->close();
'''
"Remove tags":
"prefix": "removeTags"
"body": "strip_tags()"
有人能救救我吗?我忽略了什么?
与 CoffeeScript 一样,CSON(CoffeeScript 对象表示法)是 indentation-sensitive。您示例中的前两个片段缩进正确,以下片段缩进太深了一层。
如果您不熟悉 indentation-based 语言(和格式),我建议使用 linter-coffeelint
。它标记各种语法错误。
示例:
如果您使用 JSON 感觉更自在,Atom 还支持以该格式保存的片段。
最后,这是缩进正确的代码段:
".text.html.basic, .text.html.php":
"Include jQuery":
"prefix": "jquery"
"body": "<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>"
"Basic HTML structure":
"prefix": "start"
"body": '''
<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="author" content="MagicDev">
<meta name="keywords" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
<script src="script.js"></script>
<title></title>
</head>
<body>
</body>
</html>
'''
"DB Connection":
"prefix": "connection"
"body": '''
<?php
$servername = "";
$username = "";
$password = "";
$dbname = "";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
mysqli_query($conn, "set names utf8");
?>
'''
"DB Close Connection":
"prefix": "disconnection"
"body": "$conn->close();"
"DB Insert":
"prefix": "insert"
"body": '''
$sql = $conn->prepare("INSERT INTO ${1:"table"} (${2:"attributes"})
VALUES (${3:"?,?,?"})");
$sql->bind_param("${4:"ssi"}", ${5:"variablesToInsert"});
$sql->execute();
$sql->close();
'''
"Remove tags":
"prefix": "removeTags"
"body": "strip_tags()"
我想在 Atom 中使用我自己的代码片段,但经过几个小时的尝试,我仍然无法使用超过前两个代码片段,而且我找不到错误。
当我寻找解决方案时,我发现了很多很多主题,但每个主题中的错误都是重复使用源范围,但这不是我的问题。实际上,我几乎尝试了所有方法,对语法做了很多更改,但没有任何帮助。
".text.html.basic, .text.html.php":
"Include jQuery":
"prefix": "jquery"
"body": "<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>"
"Basic HTML structure":
"prefix": "start"
"body": '''
<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="author" content="MagicDev">
<meta name="keywords" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
<script src="script.js"></script>
<title></title>
</head>
<body>
</body>
</html>
'''
"DB Connection":
"prefix": "connection"
"body": '''
<?php
$servername = "";
$username = "";
$password = "";
$dbname = "";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
mysqli_query($conn, "set names utf8");
?>
'''
"DB Close Connection":
"prefix": "disconnection"
"body": "$conn->close();"
"DB Insert":
"prefix": "insert"
"body": '''
$sql = $conn->prepare("INSERT INTO ${1:"table"} (${2:"attributes"})
VALUES (${3:"?,?,?"})");
$sql->bind_param("${4:"ssi"}", ${5:"variablesToInsert"});
$sql->execute();
$sql->close();
'''
"Remove tags":
"prefix": "removeTags"
"body": "strip_tags()"
有人能救救我吗?我忽略了什么?
与 CoffeeScript 一样,CSON(CoffeeScript 对象表示法)是 indentation-sensitive。您示例中的前两个片段缩进正确,以下片段缩进太深了一层。
如果您不熟悉 indentation-based 语言(和格式),我建议使用 linter-coffeelint
。它标记各种语法错误。
示例:
如果您使用 JSON 感觉更自在,Atom 还支持以该格式保存的片段。
最后,这是缩进正确的代码段:
".text.html.basic, .text.html.php":
"Include jQuery":
"prefix": "jquery"
"body": "<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>"
"Basic HTML structure":
"prefix": "start"
"body": '''
<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="author" content="MagicDev">
<meta name="keywords" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
<script src="script.js"></script>
<title></title>
</head>
<body>
</body>
</html>
'''
"DB Connection":
"prefix": "connection"
"body": '''
<?php
$servername = "";
$username = "";
$password = "";
$dbname = "";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
mysqli_query($conn, "set names utf8");
?>
'''
"DB Close Connection":
"prefix": "disconnection"
"body": "$conn->close();"
"DB Insert":
"prefix": "insert"
"body": '''
$sql = $conn->prepare("INSERT INTO ${1:"table"} (${2:"attributes"})
VALUES (${3:"?,?,?"})");
$sql->bind_param("${4:"ssi"}", ${5:"variablesToInsert"});
$sql->execute();
$sql->close();
'''
"Remove tags":
"prefix": "removeTags"
"body": "strip_tags()"