shiyanhui / FileHeader

A powerful file templating plugin for Sublime Text
203 stars 75 forks source link

========== 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

Installation

Package Control

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

.. _Package Control: https://sublime.wbond.net/

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

Add header to an existed file

Add header to files in the specified directory

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:

.. image:: https://raw.github.com/shiyanhui/FileHeader/master/doc/img/update.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 <http://jinja.pocoo.org/docs/>.

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.

.. code-block:: ++

    # -*- coding: utf-8 -*-
    # @Author: {{author}}
    # @Date:   {{create_time}}
    # @Last modified by:   {{last_modified_by}}
    # @Last Modified time: {{last_modified_time}}

{{ }} 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.

.. code-block:: python

    class MyClass(object):
        pass

    if __name__ == '__main__':
        pass

FAQ

Other Editors

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

.. _Jinja2: http://jinja.pocoo.org/docs/