欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

VsCode增加头部注释和函数注释

程序员文章站 2022-07-12 20:32:08
...

1. 点击文件

VsCode增加头部注释和函数注释

2.在这里插入图片描述

VsCode增加头部注释和函数注释

3.选择python,我这里已经有创建好的,所以直接点击

VsCode增加头部注释和函数注释
4.自动创建python.json
VsCode增加头部注释和函数注释

5.输入如下内容

{
	// Place your snippets for python 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"
	// }
	"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  :   Kevin ",
			"'''",
			"",
			"# here put the import lib",
			"$0" 
			
		]

	},
	"function":{
		"prefix": "function",
		"body": [
			"\"\"\"",            
			"@description  :",            
			"---------",            
			"@param  :",            
			"-------",            
			"@Returns  :",            
			"-------",           
			"\"\"\"",            
			"",            
			"$0"   
		]

	}
}

6.保存退出

测试

新建python文件

文件头部注释:在文件开头输入head,按回车

函数注释:在函数内部输入function,按回车

如下图所示:
VsCode增加头部注释和函数注释