Need help with FileHeader?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

shiyanhui
204 Stars 73 Forks 49 Commits 51 Opened issues

Description

A powerful file templating plugin for Sublime Text

Services available

!
?

Need anything else?

Contributors list

# 18,387
Go
Shell
golang
gRPC
28 commits
# 500,292
C
Shell
HTML
4 commits
# 11,218
Python
wechat-...
wechat
netlify
2 commits
# 131,882
vulkan
lwjgl
opencl
CSS
2 commits
# 369,271
Java
C
Shell
armv7
1 commit
# 487,031
Shell
C
CSS
1 commit
# 226,183
CSS
chatroo...
Socket....
express...
1 commit
# 592,408
C
Shell
PHP
1 commit

==========

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.

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

Source Installation

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

git clone [email protected]:shiyanhui/FileHeader.git

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

Usage

Create a new file

  • Sidebar Menu

.. image:: https://raw.github.com/shiyanhui/FileHeader/master/doc/img/new-file.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

.. image:: https://raw.github.com/shiyanhui/FileHeader/master/doc/img/add-header.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

.. image:: https://raw.github.com/shiyanhui/FileHeader/master/doc/img/add-header-dir.gif

A very important feature of FileHeader is that it can automatically update lastmodifiedtime and lastmodifiedby (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 
_.

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, lastmodifiedtime and lastmodifiedby 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

  • How to customize my headers?

Set customtemplateheader_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 "enableaddtemplatetoempty_file": false.

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

Just change that of FileHeader or others.

Other Editors

  • FileHeader for Atom 
    _ by
    guiguan 
    _

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

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

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.