vscode插件使用系列:1.psioniq File Header自动添加文件头

安装

使用vscode时经常需要重复性插入相同的文件头代码,或者Jekyll这种要求的固定格式文件头。使用psioniq File Header可以方便地满足这一需求,而且可以根据不同类型的文件设置生成不同的文件头内容和格式。

command + shift + P 调出命令面板找到Extensions:Install Extensions ,或者command + shift + X后在左侧切换到应用商店,搜索psioniq File Header,找到后安装即可

设置

command + shift + P 打开命令面板后输入settings,选择打开设置,打开settings.json文件

settings.json中添加如下内容后保存:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
"psi-header.config": {
"forceToTop": true
},
"psi-header.changes-tracking": {
"isActive": true,
"modAuthor": "Modified By : ",
"modDate" : "Date Modified: ",
"modDateFormat": "date",
"include": [],
"exclude": [
"markdown",
"json"
]
},
"psi-header.license-text": [
"Just have a little faith!"
],
"psi-header.variables": [
["company", "MoonWhite inc."],
["author", "mooonwhite"],
["authoremail", "moonwh173@gmail.com"]
],
"psi-header.lang-config": [
{
"language": "python",
"begin": "###",
"prefix": "# ",
"end" : "###",
"blankLinesAfter": 0,
"beforeHeader": [
"#!/usr/bin/env python3",
"# -*- coding:utf-8 -*-"
]
},
{
"language": "markdown",
"begin": "---",
"prefix": "",
"end": "---",
"blankLinesAfter": 2,
"forceToTop": true
},
{
"language": "javascript",
"begin": "/**",
"prefix": " * ",
"end": " */",
"blankLinesAfter": 2,
"forceToTop": false
}
],
"psi-header.templates": [
{
"language": "c",
"template": [
"File: <<filepath>>",
"Created Date: <<filecreated('YYYY-MM-DD HH:mm:ss')>>",
"Author: <<author>>",
"-----",
"Last Modified: <<dateformat('YYYY-MM-DD HH:mm:ss')>>",
"Modified By: ",
"-----",
"Copyright (c) <<year>> <<company>>",
"",
"<<licensetext>>",
"-----",
"HISTORY:",
"Date \tBy\tComments",
"----------\t---\t----------------------------------------------------------"
],
"changeLogCaption": "HISTORY:",
"changeLogHeaderLineCount": 2,
"changeLogEntryTemplate": [
"<<dateformat('YYYY-MM-DD')>>\t<<initials>>\t"
]
},
{
"language": "markdown",
"template": [
"layout: post",
"title: \"title\"",
"date: <<filecreated('YYYY-MM-DD hh:mm:ss')>> +0800",
"categories: web"
]
},
{
"language": "javascript",
"template": [
"File: <<filepath>>",
"Created Date: <<filecreated('dddd, MMMM Do YYYY, h:mm:ss a')>>",
"Author: <<author>>",
"-----",
"Last Modified: ",
"Modified By: ",
"-----",
"Copyright (c) <<year>> <<company>>",
"------------------------------------",
"Javascript will save your soul!"
]
},
{
"language": "typescript",
"mapTo": "javascript"
}
]

效果:新建一个markdown文件,然后连按两次热键:option + contrl + H 来自动添加文件头。