Skip to content

Latest commit

 

History

History
201 lines (167 loc) · 5.93 KB

README.md

File metadata and controls

201 lines (167 loc) · 5.93 KB

Auto Header

Logo

Github Version Github Build Status GitHub License GitHub Starts VS marketplace Version downloads installs rating semantic-release: angular

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
*/
  • html、vue、markdown
<!--
* @Author      : MerBleueAviation
* @Date        : 2018-09-27 13:55:00
* @LastEditors : MerBleueAviation
* @LastEditTime: 2018-11-08 16:10:19
-->
  • python
'''
@Author      : MerBleueAviation
@Date        : 2018-09-27 13:55:00
@LastEditors : MerBleueAviation
@LastEditTime: 2018-11-08 16:10:19
'''
  • vba
'
' @Author      : MerBleueAviation
' @Date        : 2018-09-27 13:55:00
' @LastEditors : MerBleueAviation
' @LastEditTime: 2018-11-08 16:10:19
'
  • shellscript
###
# @Author      : MerBleueAviation
# @Date        : 2018-09-27 13:55:00
# @LastEditors : MerBleueAviation
# @LastEditTime: 2018-11-08 16:10:19
###
  • lua
--[[
@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,CopyRightadditionalComment,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.namegit config user.emailcat license.md, or special value: MODIFIEDDATE, CREATEDDATE, FULLPATH, RELATIVEPATH, SHORTNAMEPATH

  • Easy configuration, you can set them in the settings UI or settings.jsonui

    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!