vscode lua代码片段推荐
时间: 2023-07-28 14:35:08 浏览: 212
以下是一些常用的VS Code Lua代码片段:
1. `for`循环:
```json
"for loop": {
"prefix": "for",
"body": [
"for i = 1, ${1:10} do",
"\t${2:print(i)}",
"end"
],
"description": "for loop"
}
```
2. `if`语句:
```json
"if statement": {
"prefix": "if",
"body": [
"if ${1:condition} then",
"\t${2:-- code}",
"end"
],
"description": "if statement"
}
```
3. `function`函数:
```json
"function": {
"prefix": "function",
"body": [
"function ${1:name}(${2:args})",
"\t${3:-- code}",
"end"
],
"description": "function"
}
```
4. `repeat-until`循环:
```json
"repeat-until loop": {
"prefix": "repeat",
"body": [
"repeat",
"\t${1:-- code}",
"until ${2:condition}"
],
"description": "repeat-until loop"
}
```
5. `while`循环:
```json
"while loop": {
"prefix": "while",
"body": [
"while ${1:condition} do",
"\t${2:-- code}",
"end"
],
"description": "while loop"
}
```
这些代码片段可以提高您的代码编写效率,您可以在 VS Code 中通过输入相应的前缀来快速使用它们。
阅读全文