用户代码片段
之前在sublime上常用tmpl插件来新建python文件,文件默认包含头文件模板。vscode可以直接添加与文件相关的代码片段。
python用户代码片段:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| {
"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 : worileqing",
"@Version : 1.0",
"@Contact : worileqing@163.com",
"@Desc : None",
"'''",
"",
"# here put the import lib",
"$0"
],
}
}
|
markdown用户代码片段:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| {
"HEADER":{
"prefix": "date",
"body": [
"date : $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
],
},
"HEADER":{
"prefix": "code is",
"body": [
"code is cheap,show code:",
],
}
}
|
但是创建完成配置未能在markdown中生效,解决办法:
在setting.json中添加:
1
2
3
4
5
6
7
| "[markdown]": {
"editor.quickSuggestions": {
"other": true,
"comments": false,
"strings": true
},
},
|
coder runner
可以在任意类型的文件里面选中代码 code run by some language