文章目录
配置vscode的java.json(依此为例子)
alt+shift+p配置
输入preferences:configure user Snippets
再输入java,点击确认,编辑java.json
或则直接按路径找到java.json
根据文件中的注释内容给出的json说明,可以自行配置
配置样例:将里面的内容用如下代码覆盖(比如:添加sout,psvm的补全效果)
{
// Place your snippets for java here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"main 代码段": {
"prefix": "psvm",
"body": [
"public static void main(String[] args){",
"\t$1",
"}"
],
"description": "main代码段"
},
"print": {
"prefix": "sout",
"body": [
"System.out.println(\"$1\");"
// "${1:}",
// ")"
],
"description": "System.out.println"
}
}
具体怎加的代码为:(可以不必深究)
"main 代码段": {
"prefix": "psvm",
"body": [
"public static void main(String[] args){",
"\t$1",
"}"
],
"description": "main代码段"
},
"print": {
"prefix": "sout",
"body": [
"System.out.println(\"$1\");"
// "${1:}",
// ")"
],
"description": "System.out.println"
}