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 22K
  • Win 13K
  • OS X 5K
  • Linux 3K
Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5
Windows 22 31 35 48 32 16 18 25 34 14 23 27 16 12 17 14 16 16 11 15 19 27 34 36 44 45 21 22 46 36 63 37 55 31 39 50 55 40 20 13 15 17 23 27 30 42
OS X 6 7 12 10 9 3 4 11 8 6 7 11 4 2 5 11 2 9 7 5 10 8 11 10 14 14 4 6 5 9 12 10 10 8 8 11 15 7 12 3 4 8 3 11 16 9
Linux 4 3 4 4 9 5 5 3 2 1 1 4 5 2 5 5 5 4 4 1 1 4 5 4 5 3 3 5 6 8 4 3 7 3 2 5 8 4 3 3 6 1 6 4 6 4

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. 🙂