zoukankan      html  css  js  c++  java
  • vscode如何自定义补全内容,自定义常用的快捷方式?

    step1
    vscode中按ctrl+shift+p,然后输入snippet,点击这个:
    在这里插入图片描述
    选择对应的语言,随后出现.json文件,这里以go语言为例:
    在这里插入图片描述
    step2:加入自己设定的快捷方式
    这段英文其实已经告诉你怎么定义了,不懂的可以看我的示例:

    {
    	// Place your snippets for go 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"
    	// }
    	//这是我自己定义的快捷方式
    	"pln":{  
    		"prefix": "pln",//输入"pln"时
    		"body": "fmt.Println($0)",//自动补全"fmt.Println($0)"
    		"description": "fmt.Println()"//描述,随便写
    	},
    	"plf":{  
    		"prefix": "plf",//输入"plf"时
    		"body": "fmt.Printf($0)",//自动补全"fmt.Printf($0)"
    		"description": "fmt.Printf()"//描述,随便写
    	}
    
    }
    

    step3:当我在编辑器中输入pln时:会自动弹出
    在这里插入图片描述
    然后回车即可:
    在这里插入图片描述
    若想一个名字的快捷方式有多个补全的可能,在.json文件中定义多个快捷方式(同prefix不同body)即可

  • 相关阅读:
    【halcon】学习记录
    【QT】常用类
    【QT】宏
    机器视觉名词解释
    单元测试
    【MFC】VS2017新建完MFC后,没有界面,只有代码
    【MFC】学习与问题整合
    函数重载(overload)和函数重写(override)
    工作记录+反思
    【转】MapReduce:默认Counter的含义
  • 原文地址:https://www.cnblogs.com/Luweir/p/14147258.html
Copyright © 2011-2022 走看看