vscode 中添加用户代码片段

很有用的功能,比如可以在文件头添加作者信息,制作模板等。

具体做法比如可以在菜单中选择 文件->首选项->用户代码片段->python 之后可以在 python.json 文件中添加相应的代码,如

{
	"HEADER":{
		"prefix": "header",
		"body": [
		"#!/usr/bin/env python",
		"# -*- encoding: utf-8 -*-",
		"'''",
		"@File    :   $TM_FILENAME",
		"@Time    :   $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
		"@Author  :   lave",
		"@Version :   1.0",
		"@Contact :   lave@abc.xyz",
		"@WebSite :   abc.xyz",
		
		"'''",
		"",
		"# here put the import lib",
		"$0"
	],
	}
}

则在输入代码的时候键入head 可自动补全上述信息。

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   abc.py
@Time    :   2019/06/08 13:11:43
@Author  :   lave
@Version :   1.0
@Contact :   lave@abc.xyz
@WebSite :   abc.xyz
'''

# here put the import lib

参考网页:

http://www.xdbcb8.com/archives/2391.html

https://www.cnblogs.com/bfc0517/p/8478037.html

https://blog.csdn.net/qq_40191093/article/details/82915028

https://www.liangzl.com/get-article-detail-11462.html

Visits: 153

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

*