ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

File​Header

by shiyanhui ST2/ST3

A powerful file templating plugin for Sublime Text

Details

Installs

  • Total 20K
  • Win 12K
  • OS X 5K
  • Linux 3K
Aug 22 Aug 21 Aug 20 Aug 19 Aug 18 Aug 17 Aug 16 Aug 15 Aug 14 Aug 13 Aug 12 Aug 11 Aug 10 Aug 9 Aug 8 Aug 7 Aug 6 Aug 5 Aug 4 Aug 3 Aug 2 Aug 1 Jul 31 Jul 30 Jul 29 Jul 28 Jul 27 Jul 26 Jul 25 Jul 24 Jul 23 Jul 22 Jul 21 Jul 20 Jul 19 Jul 18 Jul 17 Jul 16 Jul 15 Jul 14 Jul 13 Jul 12 Jul 11 Jul 10 Jul 9 Jul 8
Windows 26 35 12 18 26 24 36 32 34 19 17 31 23 29 26 21 9 15 24 25 37 39 30 16 21 23 27 28 34 32 20 28 32 40 35 35 29 14 8 23 22 26 23 22 16 19
OS X 7 8 2 2 8 4 8 4 3 7 5 10 13 3 15 8 8 8 4 10 10 5 2 8 3 7 11 5 4 9 9 7 12 10 8 7 5 2 5 7 9 4 10 13 9 11
Linux 0 8 1 2 8 2 5 8 5 2 7 9 2 5 7 5 3 2 6 5 11 4 4 3 4 5 5 4 3 6 4 4 2 3 7 8 4 3 3 10 4 2 4 8 7 2

Readme

Source
raw.​githubusercontent.​com

FileHeader

FileHeader is a powerful file templating plugin for SublimeText 2 and SublimeText 3. It makes it easier to create new file with initial contents. It also can add new header to an existed file or directory.

Features

  • Add new file with initial contents.
  • Auto detect New File action from SulimeText or other plugin.
  • Add header to an existed file or directory.
  • Batch add header to files in the specified directory.
  • Auto update file last modified time and last modified by.
  • Auto detect file type.
  • Powerful template with Jinja2.
  • Custom templates supported.
  • Rich languages supported.
  • Support both Sublime Text 2 and Sublime Text 3.

Installation

Package Control

Install Package Control. Then Package Control: Install Package, look for FileHeader and install it.

Source Installation

Go to the "Packages" directory (Preferences / Browse Packages). Then clone this repository:

git clone git@github.com:shiyanhui/FileHeader.git

Or download zip from Github, and put it in "Packages" directory (Preferences / Browse Packages).

Usage

Create a new file

  • Sidebar Menu

    /readmes/img/77b62694139973c3414057fdbc2fead80e8a7382.gif
  • Shortcuts

    The default shortcuts is super+alt+n on OS X, ctrl+alt+n on Windows and Linux.

  • Context Menu

    Similar to Sidebar Menu.

Add header to an existed file

  • Sidebar Menu

    /readmes/img/adb25e4b563e1b789042357df7999158f969f60b.gif
  • Shortcuts

    The default shortcuts is super+alt+a on OS X, ctrl+alt+a on Windows and Linux.

  • Context Menu

    Similar to Sidebar Menu.

Add header to files in the specified directory

  • Sidebar Menu

    /readmes/img/3e8c14b930401ee33f14976e99ef12514553334b.gif

A very important feature of FileHeader is that it can automatically update last_modified_time and last_modified_by (see options below). Just look this picture, take care of the @Last modified time: before save and after save:

/readmes/img/4992bcc1e89e20c5ce4448ab33ea07cc49e61c0c.gif

Settings

There are two kinds of arguments: options and kinds of languages variables settings. options is the functional setting, Default is the default language variables settings. Language variables setting will cover that in Default.

Open Preferences => Package Settings => File Header => Settings - Default for more details.

Template

FileHeader use Jinja2 template, find out how to use it here.

The template is made up of header and body. You also can write you own templates. Take the Python template header Python.tmpl for example.

{{ }} is variable, you can set it in setting files. create_time will be set when you create a new file using FileHeader, last_modified_time and last_modified_by will be update every time you save your file.

You can define your functions and classes or other contents in your body file. Also take Python template body for example.

class MyClass(object):
    pass

if __name__ == '__main__':
    pass

FAQ

  • How to customize my headers?

    Set custom_template_header_path to your path of customized header in user-settings, for example, ~/header/

    NOTE: DO NOT modify directly that in Packages/FileHeader

  • What if FileHeader conflicts with other file template plugin?

    For example, FileHeader and Javatar conflicts in files with extension .java.

    The solution is, open any file with extension .java in sublime text, and open Preferences ==> Settings - More ==> Syntax Specific - User, then add "enable_add_template_to_empty_file": false.

  • What if key-map of FileHeader conflicts with others?

    Just change that of FileHeader or others.

Other Editors

If you have any questions, please let me know. 🙂