English | 简体中文
This extension let you automatically add a header to the top of the current file. The supported comment style as bellow:
- Javascript、Java、 go、 C++、 C、C#、php、rust、solidity
/*
* @Author : MerBleueAviation
* @Date : 2018-09-27 13:55:00
* @LastEditors : MerBleueAviation
* @LastEditTime: 2018-11-08 16:10:19
*/
<!--
* @Author : MerBleueAviation
* @Date : 2018-09-27 13:55:00
* @LastEditors : MerBleueAviation
* @LastEditTime: 2018-11-08 16:10:19
-->
'''
@Author : MerBleueAviation
@Date : 2018-09-27 13:55:00
@LastEditors : MerBleueAviation
@LastEditTime: 2018-11-08 16:10:19
'''
'
' @Author : MerBleueAviation
' @Date : 2018-09-27 13:55:00
' @LastEditors : MerBleueAviation
' @LastEditTime: 2018-11-08 16:10:19
'
###
# @Author : MerBleueAviation
# @Date : 2018-09-27 13:55:00
# @LastEditors : MerBleueAviation
# @LastEditTime: 2018-11-08 16:10:19
###
--[[
@Author : MerBleueAviation
@Date : 2018-09-27 13:55:00
@LastEditors : MerBleueAviation
@LastEditTime: 2018-11-08 16:10:19
--]]
Features
Support custom comment element, except preset: Author
,CreatedDate
,LastEditors
,LastEditDate
,FilePath
,CopyRight
,additionalComment
,It could add your customer element, for example: Version
,Description
。
Support custom header comment style, support the following variables:
- First Line:
firstLineStart
, firstLineMiddle
, firstLineEnd
- Middle Line:
middleLineStart
, commentElementPrefix
, commentElementSuffix
, middleLineEnd
,
- Last Line:
lastLineStart
, lastLineMiddle
, lastLineEnd
- Others:
commentElementWidth
,lineWidth
, dateFormat
。
Support set comment element value to Command
result: git config user.name
,git config user.email
, cat license.md
, or special value: MODIFIEDDATE
, CREATEDDATE
, FULLPATH
, RELATIVEPATH
, SHORTNAMEPATH
。
Easy configuration, you can set them in the settings UI or settings.json
。
It can achieve the following effects after configurate:
/***************************************
* @Author : MerBleueAviation *
* @Date : 2018-09-27 13:55:00 *
* @LastEditors : MerBleueAviation *
* @LastEditTime: 2018-11-08 16:10:19 *
* @FilePath : RelativePath *
* @Version : 1.0.0 *
* @Description : *
* *
* Additional comments: *
* Some license information from file: *
* balabala balabala *
***************************************/
Extension Settings
enableAutoAddOnSave: true,
enableAutoAddOnNew: true,
allowCreateTimeDiff: true,
dateFormat: 'YYYY-MM-DD HH:mm:ss',
commentElements: [
'Author',
'CreatedDate',
'LastEditors',
'LastEditDate',
'FilePath',
'CopyRight'
],
commentElementsValue: {
Author: '${git config user.name}<${git config user.email}>',
CreatedDate: 'CreatedDate',
LastEditors: '${git config user.name}<${git config user.email}>',
LastEditDate: 'ModifiedDate',
FilePath: 'RelativePath',
CopyRight: ''
},
customCommentElementsValue: { YourCustomcommentElement1: '' },
style: {
'0': {
enable: true,
applyTo: 'c|cpp|h|hpp|cs|java|js|ts|go|php|rs',
firstLineStart: '/**',
firstLineMiddle: '*',
firstLineEnd: '*',
middleLineStart: ' * ',
commentElementPrefix: '@',
commentElementSuffix: ': ',
middleLineEnd: '',
lastLineStart: ' *',
lastLineMiddle: '*',
lastLineEnd: '*/',
commentElementWidth: 25,
lineWidth: 80
}
},
additionalComment: '',
enableStyleSymbolCheck: true,
logLevel: 'INFO'
If you need to add a new comment style, you can add a new style in style
:
'6': {
enable: true,
applyTo: 'unknown',
firstLineStart: "'''",
firstLineMiddle: '',
firstLineEnd: '',
middleLineStart: "''' ",
commentElementPrefix: '@',
commentElementSuffix: ': ',
middleLineEnd: '',
lastLineStart: "'''",
lastLineMiddle: '',
lastLineEnd: '',
commentElementWidth: 25,
lineWidth: 80
}
Note that the style number 6
must be unique,0
->5
are preset and reserved by extension.
Extension Commands
This extension contributes the command: Add Header
to the Command Palette.
bind key:
- win:
ctrl+alt+h
- mac:
cmd+alt+h
- linux:
ctrl+alt+h
Enjoy!