diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..fd7dad2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+.DS_Store
+*.swp
+*.pyc
+github.py
+doc/Makefile
+doc/_build/
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..3470e6f
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "doc/_themes/plain"]
+ path = doc/_themes/plain
+ url = git://github.com/hit9/sphinx-theme-rux.git
diff --git a/Context.sublime-menu b/Context.sublime-menu
new file mode 100644
index 0000000..5cb46bb
--- /dev/null
+++ b/Context.sublime-menu
@@ -0,0 +1,22 @@
+[
+ {
+ "caption": "File Header",
+ "children":
+ [
+ {
+ "caption": "New File",
+ "command": "file_header_new_file",
+ "args":{
+ "paths": []
+ }
+ },
+ {
+ "caption": "Add Header",
+ "command": "file_header_add_header",
+ "args":{
+ "paths": []
+ }
+ }
+ ]
+ }
+]
diff --git a/Default (Linux).sublime-keymap b/Default (Linux).sublime-keymap
index 8337f98..47c2bbe 100644
--- a/Default (Linux).sublime-keymap
+++ b/Default (Linux).sublime-keymap
@@ -1,15 +1,16 @@
[
{
- "keys": ["ctrl+shift+n"],
+ "keys": ["ctrl+alt+n"],
"command": "file_header_new_file",
"args":{
"paths": []
}
},
{
- "keys": ["ctrl+shift+a"],
+ "keys": ["ctrl+alt+a"],
"command": "file_header_add_header",
"args":{
+ "paths": []
}
}
]
\ No newline at end of file
diff --git a/Default (OSX).sublime-keymap b/Default (OSX).sublime-keymap
index 52cbcf7..fa5efbd 100644
--- a/Default (OSX).sublime-keymap
+++ b/Default (OSX).sublime-keymap
@@ -1,15 +1,16 @@
[
{
- "keys": ["super+shift+n"],
+ "keys": ["super+alt+n"],
"command": "file_header_new_file",
"args":{
"paths": []
}
},
{
- "keys": ["super+shift+a"],
+ "keys": ["super+alt+a"],
"command": "file_header_add_header",
"args":{
+ "paths": []
}
}
]
\ No newline at end of file
diff --git a/Default (Windows).sublime-keymap b/Default (Windows).sublime-keymap
index 8337f98..47c2bbe 100644
--- a/Default (Windows).sublime-keymap
+++ b/Default (Windows).sublime-keymap
@@ -1,15 +1,16 @@
[
{
- "keys": ["ctrl+shift+n"],
+ "keys": ["ctrl+alt+n"],
"command": "file_header_new_file",
"args":{
"paths": []
}
},
{
- "keys": ["ctrl+shift+a"],
+ "keys": ["ctrl+alt+a"],
"command": "file_header_add_header",
"args":{
+ "paths": []
}
}
]
\ No newline at end of file
diff --git a/Default.sublime-commands b/Default.sublime-commands
new file mode 100644
index 0000000..cfef97b
--- /dev/null
+++ b/Default.sublime-commands
@@ -0,0 +1,16 @@
+[
+ {
+ "caption": "FileHeader: New File",
+ "command": "file_header_new_file",
+ "args": {
+ "paths": []
+ }
+ },
+ {
+ "caption": "FileHeader: Add Header",
+ "command": "file_header_add_header",
+ "args": {
+ "paths": []
+ }
+ }
+]
diff --git a/FileHeader.py b/FileHeader.py
index 1f05d96..d447a6a 100644
--- a/FileHeader.py
+++ b/FileHeader.py
@@ -1,131 +1,705 @@
# -*- coding: utf-8 -*-
+# @Author: Lime
+# @Date: 2013-10-28 13:39:48
+# @Last Modified by: pospi
+# @Last Modified time: 2016-07-22
-import sublime
-import sublime_plugin
import os
import sys
+import re
import functools
-
+import threading
+import zipfile
+import getpass
+import shutil
+import pickle
+import filecmp
+import subprocess
from datetime import datetime
-ROOT_PATH = os.path.abspath(os.path.dirname(__file__))
-TEMPLATE_PATH = ROOT_PATH + '/template/'
+import sublime
+import sublime_plugin
+
+PLUGIN_NAME = 'FileHeader'
+INSTALLED_PLUGIN_NAME = '%s.sublime-package' % PLUGIN_NAME
+PACKAGES_PATH = sublime.packages_path()
+PLUGIN_PATH = os.path.join(PACKAGES_PATH, PLUGIN_NAME)
+HEADER_PATH = os.path.join(PLUGIN_PATH, 'template/header')
+BODY_PATH = os.path.join(PLUGIN_PATH, 'template/body')
+INSTALLED_PLGIN_PATH = os.path.abspath(os.path.dirname(__file__))
+
+IS_ST3 = sublime.version() >= '3'
+
+sys.path.insert(0, PLUGIN_PATH)
+
+
+def plugin_loaded():
+ '''ST3'''
+
+ global LOADED
+ global PACKAGES_PATH
+ global PLUGIN_PATH
+ global HEADER_PATH
+ global BODY_PATH
+ global INSTALLED_PLGIN_PATH
+ global IS_ST3
+
+ PLUGIN_NAME = 'FileHeader'
+ INSTALLED_PLUGIN_NAME = '%s.sublime-package' % PLUGIN_NAME
+
+ PACKAGES_PATH = sublime.packages_path()
+ PLUGIN_PATH = os.path.join(PACKAGES_PATH, PLUGIN_NAME)
+ HEADER_PATH = os.path.join(PLUGIN_PATH, 'template/header')
+ BODY_PATH = os.path.join(PLUGIN_PATH, 'template/body')
+ INSTALLED_PLGIN_PATH = os.path.abspath(os.path.dirname(__file__))
+
+ IS_ST3 = sublime.version() >= '3'
+
+ sys.path.insert(0, PLUGIN_PATH)
+
+ if INSTALLED_PLGIN_PATH != PLUGIN_PATH:
+ _ = os.path.join(PLUGIN_PATH, INSTALLED_PLUGIN_NAME)
+ if os.path.exists(_) and filecmp.cmp(_, INSTALLED_PLGIN_PATH):
+ return
+
+ if os.path.exists(PLUGIN_PATH):
+ try:
+ shutil.rmtree(PLUGIN_PATH)
+ except:
+ pass
+
+ if not os.path.exists(PLUGIN_PATH):
+ os.mkdir(PLUGIN_PATH)
+
+ z = zipfile.ZipFile(INSTALLED_PLGIN_PATH, 'r')
+ for f in z.namelist():
+ z.extract(f, PLUGIN_PATH)
+ z.close()
+
+ shutil.copyfile(INSTALLED_PLGIN_PATH, _)
+
+
+def getOutputError(cmd):
+ return map(str.strip, subprocess.Popen(
+ cmd, shell=True, universal_newlines=True,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate())
-sys.path.insert(0, ROOT_PATH)
def Window():
+ '''Get current active window'''
+
return sublime.active_window()
-def refresh():
+
+def get_setting(key, default = None):
+ '''Get settings'''
+ value = sublime.load_settings('%s.sublime-settings' % PLUGIN_NAME).get(key)
+ projectOverride = None
+
+ # Load override from project settings if present
+ project_settings = Window().active_view().settings()
+ if project_settings.has(PLUGIN_NAME):
+ projectOverride = project_settings.get(PLUGIN_NAME).get(key)
+
+ if value is None and projectOverride is None:
+ return default
+
+ return value if projectOverride is None else projectOverride
+
+
+def get_template_part(syntax_type, part):
+ '''Get template header or body'''
+
+ template_name = '%s.tmpl' % syntax_type
+ tmplate_path = os.path.join(
+ HEADER_PATH if part == 'header' else BODY_PATH, template_name)
+
+ custom_template_path = get_setting('custom_template_%s_path' % part)
+ if custom_template_path:
+ path = os.path.abspath(os.path.expanduser(os.path.expandvars(
+ os.path.join(custom_template_path, template_name))))
+
+ if os.path.exists(path) and os.path.isfile(path):
+ tmplate_path = path
+
+ try:
+ with open(tmplate_path, 'r') as f:
+ contents = f.read()
+ except:
+ contents = ''
+ return contents
+
+
+def get_template(syntax_type):
+ return ''.join([
+ get_template_part(syntax_type, part)
+ for part in ['header', 'body']
+ ])
+
+
+def get_strftime():
+ '''Get `time_format` setting'''
+
+ _ = ['%Y-%m-%d %H:%M:%S', '%Y-%m-%d', '%H:%M:%S']
+
+ format = get_setting('custom_time_format')
+
+ if not format:
+ try:
+ format = _[get_setting('time_format')]
+ except IndexError:
+ format = _[0]
+
+ return format
+
+
+def get_user():
+ '''Get user'''
+
+ user = getpass.getuser()
+ output, error = getOutputError(
+ 'cd {0} && git status'.format(get_dir_path()))
+
+ if not error:
+ output, error = getOutputError('git config --get user.name')
+ if not error and output:
+ user = output
+ return user
+
+
+def get_project_name():
+ '''Get project name'''
+
+ project_data = sublime.active_window().project_data()
+ project = os.path.basename(
+ project_data['folders'][0]['path']) if project_data else None
+
+ return project
+
+
+def get_dir_path():
+ '''Get current file dir path'''
+
+ view, path = Window().active_view(), None
+ if view:
+ file_name = view.file_name()
+ if file_name is not None:
+ path = os.path.dirname(file_name)
+ return path
+
+
+def get_file_path(path):
+ '''Get absolute path of the file'''
+
+ return 'undefined' if path is None else path
+
+
+def get_file_name(path):
+ '''Get name of the file'''
+
+ return 'undefined' if path is None else os.path.basename(path)
+
+
+def get_file_name_without_extension(file_name):
+ '''Get name of the file without extension'''
+
+ return '.'.join(file_name.split('.')[:-1]) or file_name
+
+
+def get_time(path):
+ c_time = m_time = None
try:
- sublime.set_timeout(lambda:sublime.active_window().run_command('refresh_folder_list'), 200);
- sublime.set_timeout(lambda:sublime.active_window().run_command('refresh_folder_list'), 1300);
+ stat = os.stat(path)
except:
pass
+ else:
+ c_time, m_time = map(
+ datetime.fromtimestamp, (stat.st_ctime, stat.st_mtime))
-class FileHeaderNewFileCommand(sublime_plugin.WindowCommand):
- def get_template(self, syntax_type):
- template_file = open('%s%s.tmpl' % (TEMPLATE_PATH, syntax_type), 'r')
- contents = template_file.read() + '\n'
- template_file.close()
- return contents
-
- def render_template(self, syntax_type):
- from jinja2 import Template
- template = Template(self.get_template(syntax_type))
- render_string = template.render({'author': 'Lime',
- 'date': datetime.now() })
- return render_string
-
- def syntax_type(self, name, syntax_type='Text'):
+ return c_time, m_time
+
+
+def get_args(syntax_type, options={}):
+ '''Get the args rendered.
+
+ :Para:
+ - `syntax_type`: Language type
+ - `which`: candidates are 'new' and 'add'
+ '''
+
+ def get_st3_time():
+ _ = c_time = m_time = datetime.now()
+
+ path = options.get('path', None)
+ if path is not None:
+ c_time, m_time = get_time(path)
+
+ if c_time is None:
+ c_time = m_time = _
+
+ return c_time, m_time
+
+ def get_st2_time():
+ c_time, m_time = get_st3_time()
+ _ = options.get('c_time', None)
+ if _ is not None:
+ c_time = _
+
+ return c_time, m_time
+
+ args = get_setting('Default')
+ args.update(get_setting(syntax_type, {}))
+
+ format = get_strftime()
+ c_time, m_time = get_st3_time() if IS_ST3 else get_st2_time()
+
+ file_path = get_file_path(options.get('path', None))
+ file_name = get_file_name(options.get('path', None))
+ file_name_without_extension = get_file_name_without_extension(file_name)
+
+ args.update({
+ 'create_time': c_time.strftime(format),
+ 'last_modified_time': m_time.strftime(format),
+ 'file_name': file_name,
+ 'file_name_without_extension': file_name_without_extension,
+ 'file_path': file_path
+ })
+
+ if IS_ST3:
+ args.update({'project_name': get_project_name()})
+
+ user = get_user()
+ if 'author' not in args:
+ args.update({'author': user})
+ if 'last_modified_by' not in args:
+ args.update({'last_modified_by': user})
+
+ return args
+
+
+def render_template(syntax_type, part=None, options={}):
+ '''Render the template correspond `syntax_type`'''
+
+ from jinja2 import Template
+ try:
+ template = Template(
+ get_template_part(syntax_type, part)
+ if part else get_template(syntax_type))
+ render_string = template.render(get_args(syntax_type, options))
+ except:
+ render_string = ''
+ return render_string
+
+
+def get_syntax_type(name):
+ '''Judge `syntax_type` according to to `name`'''
+
+ syntax_type = get_setting('syntax_when_not_match')
+ file_suffix_mapping = get_setting('file_suffix_mapping')
+ extension_equivalence = get_setting('extension_equivalence')
+
+ if name is not None:
name = name.split('.')
if len(name) <= 1:
return syntax_type
- syntax_map = {
- 'asp': 'ASP',
- 'c': 'C++',
- 'cs': 'C#',
- 'cpp': 'C++',
- 'css': 'CSS',
- 'go': 'Go',
- 'htm': 'HTML',
- 'html': 'HTML',
- 'java': 'Java',
- 'js': 'JavaScript',
- 'pl': 'Perl',
- 'php': 'PHP',
- 'py': 'Python',
- 'rb': 'Ruby',
- 'txt': 'Text',
- 'xml': 'XML',
- }
+ for i in range(1, len(name)):
+ suffix = '.'.join(name[i:])
+ if suffix in extension_equivalence:
+ suffix = extension_equivalence[suffix]
+ break
+ else:
+ suffix = name[-1]
try:
- syntax_type = syntax_map[name[-1]]
+ syntax_type = file_suffix_mapping[suffix]
except KeyError:
pass
- return syntax_type
+ return syntax_type
- def get_syntax_file(self, syntax_type):
- return 'Packages/%s/%s.tmLanguage' % (syntax_type, syntax_type)
- def on_done(self, paths, name):
- if not name:
- return
+def get_syntax_file(syntax_type):
+ '''Get syntax file path'''
- syntax_type = self.syntax_type(name)
- header = self.render_template(syntax_type)
+ lang2tmL = {
+ 'Graphviz': 'DOT',
+ 'RestructuredText': 'reStructuredText',
+ 'ShellScript': 'Shell-Unix-Generic',
+ 'TCL': 'Tcl',
+ 'Text': 'Plain text',
+ }
- if not paths:
- new_file = Window().new_file()
- new_file.set_name(name)
- new_file.run_command('insert', {'characters': header})
- new_file.set_syntax_file(self.get_syntax_file(syntax_type))
- return
-
- paths = paths[0]
- if(os.path.isdir(paths)):
- file_name = os.path.join(paths, name)
+ if syntax_type == 'C':
+ syntax_type = 'C++'
+
+ tmL = lang2tmL.get(syntax_type, syntax_type)
+ return 'Packages/%s/%s.tmLanguage' % (syntax_type, tmL)
+
+
+def block(view, callback, *args, **kwargs):
+ '''Ensure the callback is executed'''
+
+ def _block():
+ if view.is_loading():
+ sublime.set_timeout(_block, 100)
else:
- file_name = os.path.join(os.path.dirname(paths), name)
+ callback(*args, **kwargs)
- if os.path.exists(file_name):
+ _block()
+
+
+class FileHeaderNewFileCommand(sublime_plugin.WindowCommand):
+ '''Create a new file with header'''
+
+ def new_file(self, path, syntax_type):
+ if os.path.exists(path):
sublime.error_message('File exists!')
return
+ header = render_template(syntax_type, options={'path': path})
+
try:
- with open(file_name, 'w+') as f:
+ with open(path, 'w+') as f:
f.write(header)
- f.close()
- except Exception(e):
- sublime.error_message(e)
+
+ except Exception as e:
+ sublime.error_message(str(e))
return
- new_file = Window().open_file(file_name)
- new_file.set_syntax_file(self.get_syntax_file(syntax_type))
- refresh()
+ new_file = Window().open_file(path)
+
+ try:
+ block(new_file,
+ new_file.set_syntax_file, get_syntax_file(syntax_type))
+ except:
+ pass
+
+ block(new_file, new_file.show, 0)
+
+ def new_view(self, syntax_type, name):
+ header = render_template(syntax_type)
+ new_file = Window().new_file()
+ new_file.set_name(name)
+ new_file.run_command('insert', {'characters': header})
+
+ try:
+ new_file.set_syntax_file(get_syntax_file(syntax_type))
+ except:
+ pass
+
+ def get_path(self, paths):
+ path = None
+ if not paths:
+ path = get_dir_path()
+ else:
+ path = paths[0]
+ if not os.path.isdir(path):
+ path = os.path.dirname(path)
+
+ if path is not None:
+ path = os.path.abspath(path)
+
+ return path
+
+ def on_done(self, path, name):
+ if not name:
+ return
+
+ syntax_type = get_syntax_type(name)
+
+ if path is None:
+ self.new_view(syntax_type, name)
+ else:
+ path = os.path.join(path, name)
+ self.new_file(path, syntax_type)
def run(self, paths=[]):
- Window().run_command('hide_panel');
- Window().show_input_panel(caption='File Name:', initial_text='',
- on_done=functools.partial(self.on_done, paths
- ), on_change=None, on_cancel=None)
-
-class FileHeaderAddHeaderCommand(sublime_plugin.TextCommand):
- def get_template(self):
- template_file = open(TEMPLATE_PATH + 'python.tmpl', 'r')
- contents = template_file.read() + '\n'
- template_file.close()
- return contents
-
- def render_template(self):
- template = Template(self.get_template())
- render_string = template.render({'author': 'Lime',
- 'date': datetime.now() })
- return render_string
-
- def run(self, edit):
- header = self.render_template()
+ path = self.get_path(paths)
+
+ Window().run_command('hide_panel')
+ Window().show_input_panel(
+ 'File Name:', '',
+ functools.partial(self.on_done, path), None, None)
+
+
+class BackgroundAddHeaderThread(threading.Thread):
+ '''Add header in background.'''
+
+ def __init__(self, path):
+ self.path = path
+ super(BackgroundAddHeaderThread, self).__init__()
+
+ def run(self):
+ syntax_type = get_syntax_type(self.path)
+ header = render_template(syntax_type, 'header', {'path': self.path})
+
+ try:
+ with open(self.path, 'r') as f:
+ contents = header + f.read()
+
+ with open(self.path, 'w') as f:
+ f.write(contents)
+
+ except Exception as e:
+ sublime.error_message(str(e))
+
+
+class AddFileHeaderCommand(sublime_plugin.TextCommand):
+ '''Command: add `header` in a file'''
+
+ def run(self, edit, path, part=None):
+ syntax_type = get_syntax_type(path)
+
+ options = {'path': path}
+ if not IS_ST3:
+ c_time = self.view.settings().get('c_time', None)
+ if c_time is not None:
+ c_time = pickle.loads(str(c_time))
+ options.update({'c_time': c_time})
+
+ header = render_template(syntax_type, part, options)
self.view.insert(edit, 0, header)
+
+
+class FileHeaderAddHeaderCommand(sublime_plugin.WindowCommand):
+ '''Conmmand: add `header` in a file or directory'''
+
+ def is_hidden(self, path):
+ '''Whether the file or dir is hidden'''
+
+ hidden, platform = False, sublime.platform()
+ if platform == 'windows':
+ output, error = getOutputError('attrib %s' % path)
+ if not error:
+ try:
+ if output[4].upper() == 'H':
+ hidden = True
+ except:
+ pass
+ elif os.path.basename(path).startswith('.'):
+ hidden = True
+ return hidden
+
+ def can_add(self, path):
+ '''Whether can add header to path'''
+
+ def can_add_to_dir(path):
+ return enable_add_to_hidden_dir or (
+ not enable_add_to_hidden_dir and
+ not self.is_hidden(path))
+
+ def can_add_to_file(path):
+ return enable_add_to_hidden_file or (
+ not enable_add_to_hidden_file and
+ not self.is_hidden(path))
+
+ if not os.path.exists(path):
+ return False
+
+ enable_add_to_hidden_dir, enable_add_to_hidden_file = map(
+ get_setting, (
+ 'enable_add_header_to_hidden_dir',
+ 'enable_add_header_to_hidden_file'
+ )
+ )
+
+ if (os.path.isfile(path) and
+ can_add_to_dir(os.path.dirname(path)) and
+ can_add_to_file(path)):
+ return True
+
+ elif os.path.isdir(path):
+ return can_add_to_dir(path)
+
+ return False
+
+ def add(self, path):
+ '''Add to a file'''
+
+ whether_open_file = get_setting(
+ 'open_file_when_add_header_to_directory')
+
+ if whether_open_file:
+ modified_file = Window().open_file(path)
+ block(modified_file, modified_file.run_command,
+ 'add_file_header', {'path': path, 'part': 'header'})
+ block(modified_file, modified_file.show, 0)
+ else:
+ BackgroundAddHeaderThread(path).start()
+
+ def walk(self, path):
+ '''Add files in the path'''
+
+ for root, subdirs, files in os.walk(path):
+ for f in files:
+ file_name = os.path.join(root, f)
+ if self.can_add(file_name):
+ self.add(file_name)
+
+ def on_done(self, path):
+ if not path:
+ return
+
+ if not os.path.exists(path):
+ sublime.error_message('Path not exists!')
+ return
+
+ path = os.path.abspath(path)
+ if os.path.isfile(path) and self.can_add(path):
+ self.add(path)
+
+ elif os.path.isdir(path) and self.can_add(path):
+ self.walk(path)
+
+ def run(self, paths=[]):
+ initial_text = ''
+ if paths:
+ initial_text = os.path.abspath(paths[0])
+ else:
+ try:
+ initial_text = Window().active_view().file_name()
+ except:
+ pass
+
+ show_input_panel_when_add_header = get_setting(
+ 'show_input_panel_when_add_header')
+
+ if not show_input_panel_when_add_header:
+ self.on_done(initial_text)
+ return
+
+ Window().run_command('hide_panel')
+ Window().show_input_panel(
+ 'Modified File or Directory:',
+ initial_text, self.on_done, None, None)
+
+
+class FileHeaderReplaceCommand(sublime_plugin.TextCommand):
+ '''Replace contents in the `region` with `stirng`'''
+
+ def run(self, edit, a, b, strings):
+ region = sublime.Region(int(a), int(b))
+ self.view.replace(edit, region, strings)
+
+
+LAST_MODIFIED_BY = 'LAST_MODIFIED_BY'
+LAST_MODIFIED_TIME = 'LAST_MODIFIED_TIME'
+FILE_NAME = 'FILE_NAME'
+FILE_NAME_WITHOUT_EXTENSION = 'FILE_NAME_WITHOUT_EXTENSION'
+FILE_PATH = 'FILE_PATH'
+
+
+class FileHeaderListener(sublime_plugin.EventListener):
+ LAST_MODIFIED_BY_REGEX = re.compile('\{\{\s*last_modified_by\s*\}\}')
+ LAST_MODIFIED_TIME_REGEX = re.compile('\{\{\s*last_modified_time\s*\}\}')
+ FILE_NAME_REGEX = re.compile('\{\{\s*file_name\s*\}\}')
+ FILE_NAME_WITHOUT_EXTENSION_REGEX = re.compile(
+ '\{\{\s*file_name_without_extension\s*\}\}')
+ FILE_PATH_REGEX = re.compile('\{\{\s*file_path\s*\}\}')
+
+ new_view_id = []
+
+ def update_automatically(self, view, what):
+ syntax_type = get_syntax_type(view.file_name())
+
+ line_pattern = None
+ lines = get_template_part(syntax_type, 'header').split('\n')
+ regex = getattr(FileHeaderListener, '%s_REGEX' % what)
+
+ for line in lines:
+ search = regex.search(line)
+ if search is not None:
+ variable = search.group()
+ index = line.find(variable)
+
+ line_head, line_tail = '', line[index + len(variable):]
+ for i in range(index - 1, -1, -1):
+ if line[i] != ' ':
+ space_start = i + 1
+ line_head = line[:space_start]
+ break
+
+ for r in '.^$*+?{}[]()':
+ line_head = line_head.replace(r, '\\{0}'.format(r))
+
+ line_pattern = '{0}.*\n'.format(line_head)
+ break
+
+ if line_pattern is not None:
+ _ = view.find(line_pattern, 0)
+ if(_ != sublime.Region(-1, -1) and _ is not None):
+ a, b = _.a + space_start, _.b - 1
+ file_name = get_file_name(view.file_name())
+
+ if what == LAST_MODIFIED_BY:
+ strings = get_args(syntax_type)['last_modified_by']
+ elif what == LAST_MODIFIED_TIME:
+ strings = datetime.now().strftime(get_strftime())
+ elif what == FILE_NAME:
+ strings = file_name
+ elif what == FILE_NAME_WITHOUT_EXTENSION:
+ strings = get_file_name_without_extension(file_name)
+ elif what == FILE_PATH:
+ strings = get_file_path(view.file_name())
+
+ strings = '{0}{1}{2}'.format(
+ ' ' * (index - space_start), strings, line_tail)
+
+ region = sublime.Region(int(a), int(b))
+ if view.substr(region) != strings:
+ view.run_command(
+ 'file_header_replace',
+ {'a': a, 'b': b, 'strings': strings})
+
+ def insert_template(self, view, exists):
+ enable_add_template_to_empty_file = get_setting(
+ 'enable_add_template_to_empty_file') and view.settings().get(
+ 'enable_add_template_to_empty_file', True)
+
+ path = view.file_name()
+ condition = (path and enable_add_template_to_empty_file
+ and view.size() <= 0)
+
+ if exists:
+ condition = (
+ condition
+ and os.path.exists(path)
+ and os.path.isfile(path)
+ and os.path.getsize(path) <= 0
+ )
+
+ if condition:
+ block(view, view.run_command, 'add_file_header', {'path': path})
+ block(view, view.show, 0)
+
+ def on_new(self, view):
+ FileHeaderListener.new_view_id.append(view.id())
+
+ def on_text_command(self, view, command_name, args):
+ if command_name == 'undo' or command_name == 'soft_undo':
+ while view.command_history(0)[0] == 'file_header_replace':
+ view.run_command('undo')
+
+ def on_pre_save(self, view):
+ if view.id() in FileHeaderListener.new_view_id:
+ self.insert_template(view, False)
+ index = FileHeaderListener.new_view_id.index(view.id())
+ del FileHeaderListener.new_view_id[index]
+ else:
+ if view.is_dirty():
+ self.update_automatically(view, LAST_MODIFIED_BY)
+ self.update_automatically(view, LAST_MODIFIED_TIME)
+
+ def on_activated(self, view):
+ block(view, self.update_automatically, view, FILE_PATH)
+ block(view, self.update_automatically, view, FILE_NAME)
+ block(view, self.update_automatically,
+ view, FILE_NAME_WITHOUT_EXTENSION)
+
+ settings = view.settings()
+ c_time, _ = get_time(view.file_name())
+ if c_time is not None and settings.get('c_time', None) is None:
+ settings.set('c_time', pickle.dumps(c_time))
+
+ self.insert_template(view, True)
diff --git a/FileHeader.sublime-settings b/FileHeader.sublime-settings
index 9fbe038..57702d7 100644
--- a/FileHeader.sublime-settings
+++ b/FileHeader.sublime-settings
@@ -1,6 +1,269 @@
{
- "date" : "%Y-%m-%d %H:%M:%S",
- "author": "Your Name",
- "email": "you@example.com",
- "link": "http://example.com"
-}
\ No newline at end of file
+ /*
+ options
+ =======
+ */
+
+ /*
+ The datetime format.
+
+ 0: "%Y-%m-%d %H:%M:%S"
+ 1: "%Y-%m-%d"
+ 2: "%H:%M:%S"
+ */
+ "time_format": 0,
+ /*
+ The custom time format. It will format `create_time` and `last_modified_time`
+ instead of `time_format` if you set it. The time format refers to`
+ https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior`.
+ */
+ "custom_time_format": "",
+ /*
+ Whether add template to the empty file.
+
+ It's useful when you create new file through other command, for
+ example, the default Sublime Text's **New File...** or other plugin.
+ */
+ "enable_add_template_to_empty_file": true,
+ /*
+ Set your custom template header path here, it is a directory in which
+ you write your own header files. The file name should be a language,
+ "Python.tmpl" for example.
+ */
+ "custom_template_header_path": "",
+ /*
+ Set your custom template body path here, it is a directory in which
+ you write your own body files. The file name should be a language,
+ "Python.tmpl" for example.
+
+ The template structure is:
+
+ I am a file
+ -----------
+ header
+ body
+
+ */
+ "custom_template_body_path": "",
+ /*
+ Whether show input panel when you add header. The default file which
+ you add header to is the current file you edit.
+ */
+ "show_input_panel_when_add_header": true,
+ /*
+ Whether open file when you add header to files in the specified
+ directory.
+ */
+ "open_file_when_add_header_to_directory": true,
+ /*
+ Whether enable add header to hidden directory. If false, FileHeader
+ won't add header to files under it.
+ */
+ "enable_add_header_to_hidden_dir": false,
+ /*
+ Whether enable add header to hidden file. If false, FileHeader
+ won't add header to it.
+ */
+ "enable_add_header_to_hidden_file": false,
+ /*
+ FileHeader judges programming language according file suffix.
+
+ Default programming language if FileHeader judges failed when you
+ create new file.
+ */
+ "syntax_when_not_match": "Text",
+ /*
+ FileHeader will judge programming language according to file suffix.
+ You can add more file suffix here. Note: language should be one of
+ that under **Default**. If FileHeader don't find the suffix,
+ FileHeader will set language as **syntax_when_not_match** above.
+ */
+ "file_suffix_mapping": {
+ "as": "ActionScript",
+ "scpt": "AppleScript",
+ "asp": "ASP",
+ "aspx": "ASP",
+ "bat": "Batch File",
+ "cmd": "Batch File",
+ "c": "C",
+ "cs": "C#",
+ "cpp": "C++",
+ "clj": "Clojure",
+ "css": "CSS",
+ "D": "D",
+ "erl": "Erlang",
+ "go": "Go",
+ "groovy": "Groovy",
+ "hs": "Haskell",
+ "htm": "HTML",
+ "html": "HTML",
+ "java": "Java",
+ "js": "JavaScript",
+ "tex": "LaTeX",
+ "lsp": "Lisp",
+ "lua": "Lua",
+ "md": "Markdown",
+ "mat": "Matlab",
+ "m": "Objective-C",
+ "ml": "OCaml",
+ "p": "Pascal",
+ "pl": "Perl",
+ "php": "PHP",
+ "py": "Python",
+ "R": "R",
+ "rst": "RestructuredText",
+ "rb": "Ruby",
+ "scala": "Scala",
+ "scss": "SCSS",
+ "sh": "ShellScript",
+ "sql": "SQL",
+ "tcl": "TCL",
+ "txt": "Text",
+ "xml": "XML"
+ },
+ /*
+ Set special file suffix equivalence. Take `blade.php` for example,
+ FileHeader will initial file with suffix `blade.php` with that of `html`.
+
+ */
+ "extension_equivalence": {
+ "blade.php": "html"
+ },
+
+ /*
+ Variables
+ =========
+ */
+
+ /*
+ Below is the variables you render templater.
+ */
+ "Default": {
+ /*
+ Builtin Variables
+ =================
+
+ - create_time
+
+ The file created time. It will be automatically set when you create
+ a new file if you use it.
+
+ Can't be set custom.
+
+ - author
+
+ The file creator.
+
+ FileHeader will set it automatically. If it's in
+ a git repository and the `user.name` has been set, `autor`
+ will set to `user.name`, otherwise it will be set to current
+ system user.
+
+ Can be set custom.
+
+ - last_modified_by
+
+ The file last modified by who? It is specially useful when
+ cooperation programming.
+
+ FileHeader will set it automatically. If it's in
+ a git repository and the `user.name` has been set, `autor`
+ will set to `user.name`, otherwise it will be set to current
+ system logined user.
+
+ Can be set custom.
+
+ - last_modified_time
+
+ The file last modified time.
+
+ FileHeader will set it automatically when you save the file.
+
+ Can't be set custom.
+
+ - file_path
+
+ The absolute path of the current file.
+
+ FileHeader will update it automatically when you change it.
+
+ Can't be set custom.
+
+ - file_name
+
+ The name of current file with extension.
+
+ FileHeader will update it automatically when you change it.
+
+ Can't be set custom.
+
+ - file_name_without_extension
+
+ The name of current file without extension.
+
+ FileHeader will update it automatically when you change it.
+
+ Can't be set custom.
+
+ - project_name
+
+ The project name.
+
+ Note: `project_name` only works in ST3.
+
+ Can't be set custom.
+ */
+
+ /*
+ Email
+ */
+ "email": "email@example.com"
+
+ // You can add more here......
+ },
+ /*
+ You can set different variables in different languages. It will cover
+ that in "Default".
+ */
+ "ASP": {},
+ "ActionScript": {},
+ "AppleScript": {},
+ "Batch File": {},
+ "C#": {},
+ "C++": {},
+ "CSS": {},
+ "Clojure": {},
+ "D": {},
+ "Diff": {},
+ "Erlang": {},
+ "Go": {},
+ "Graphviz": {},
+ "Groovy": {},
+ "HTML": {},
+ "Haskell": {},
+ "Java": {},
+ "JavaScript": {},
+ "LaTeX": {},
+ "Lisp": {},
+ "Lua": {},
+ "Makefile": {},
+ "Markdown": {},
+ "Matlab": {},
+ "OCaml": {},
+ "Objective-C": {},
+ "PHP": {},
+ "Pascal": {},
+ "Perl": {},
+ "Python": {},
+ "R": {},
+ "RestructuredText": {},
+ "Ruby": {},
+ "SQL": {},
+ "Scala": {},
+ "ShellScript": {},
+ "TCL": {},
+ "Text": {},
+ "Textile": {},
+ "XML": {},
+ "YAML": {}
+}
diff --git a/Main.sublime-menu b/Main.sublime-menu
index 164ade9..84fc0da 100644
--- a/Main.sublime-menu
+++ b/Main.sublime-menu
@@ -13,7 +13,6 @@
"caption": "File Header",
"children":
[
-
{
"command": "open_file",
"args": {"file": "${packages}/FileHeader/FileHeader.sublime-settings"},
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..750eaba
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,167 @@
+==========
+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 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
+
+ .. image:: https://raw.github.com/shiyanhui/shiyanhui.github.io/master/images/FileHeader/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/shiyanhui.github.io/master/images/FileHeader/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/shiyanhui.github.io/master/images/FileHeader/add-header-dir.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:
+
+.. image:: https://raw.github.com/shiyanhui/shiyanhui.github.io/master/images/FileHeader/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, **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
+===
+
+- **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
+=============
+
+- `FileHeader for Atom `_ by `guiguan `_
+
+If you have any questions, please let me know. 🙂
+
+.. _Jinja2: http://jinja.pocoo.org/docs/
diff --git a/Side Bar.sublime-menu b/Side Bar.sublime-menu
index cf4c1c8..41a86f2 100644
--- a/Side Bar.sublime-menu
+++ b/Side Bar.sublime-menu
@@ -1,10 +1,10 @@
[
- {
+ {
"caption": "File Header",
"children":
[
{ "caption": "New File...", "command": "file_header_new_file", "args": {"paths": []} },
- { "caption": "Add Header...", "command": "file_header_add_header", "args": {} }
+ { "caption": "Add Header...", "command": "file_header_add_header", "args": {"paths": []} }
]
}
]
diff --git a/doc/_themes/plain b/doc/_themes/plain
new file mode 160000
index 0000000..942fe15
--- /dev/null
+++ b/doc/_themes/plain
@@ -0,0 +1 @@
+Subproject commit 942fe1526ade359c9829f70667fc02725829a1dd
diff --git a/doc/conf.py b/doc/conf.py
new file mode 100644
index 0000000..6ff9d8b
--- /dev/null
+++ b/doc/conf.py
@@ -0,0 +1,265 @@
+# -*- coding: utf-8 -*-
+#
+# FileHeader documentation build configuration file, created by
+# sphinx-quickstart on Sat Jun 28 09:25:34 2014.
+#
+# This file is execfile()d with the current directory set to its
+# containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys
+import os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration ------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = []
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'FileHeader'
+copyright = u'2014, Lime'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '1.5.6'
+# The full version, including alpha/beta/rc tags.
+release = '1.5.6'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+# If true, keep warnings as "system message" paragraphs in the built documents.
+#keep_warnings = False
+
+
+# -- Options for HTML output ----------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# " v documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# Add any extra paths that contain custom files (such as robots.txt or
+# .htaccess) here, relative to this directory. These files are copied
+# directly to the root of the documentation.
+#html_extra_path = []
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'FileHeaderdoc'
+
+
+# -- Options for LaTeX output ---------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+# author, documentclass [howto, manual, or own class]).
+latex_documents = [
+ ('index', 'FileHeader.tex', u'FileHeader Documentation',
+ u'Lime', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output ---------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+ ('index', 'fileheader', u'FileHeader Documentation',
+ [u'Lime'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output -------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+# dir menu entry, description, category)
+texinfo_documents = [
+ ('index', 'FileHeader', u'FileHeader Documentation',
+ u'Lime', 'FileHeader', 'One line description of project.',
+ 'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#texinfo_no_detailmenu = False
+
+sys.path.append(os.path.abspath('_themes'))
+html_theme_path = ['_themes']
+html_theme = 'plain'
+html_theme_options = {
+ 'github': 'shiyanhui'
+}
\ No newline at end of file
diff --git a/doc/index.rst b/doc/index.rst
new file mode 100644
index 0000000..13a81da
--- /dev/null
+++ b/doc/index.rst
@@ -0,0 +1,77 @@
+**FileHeader** 是一个Sublime Text的File Templating插件。目前ST已经有几款File Templating插件了,像SublimeTmpl、TemplateNinja、FileTemplates等,但是这些插件的功能太简单了,他们几乎都使用了ST的内置snippets来实现模板的渲染,并且支持的语言很有限(像SublimeTmpl仅支持Python、Ruby、JavaScript、PHP、HTML、CSS、XML),有的插件仅仅支持ST2(FileTemplates),还有的使用起来及其不效率。
+
+本插件与其他插件有很大的不同。
+
+- 将一个模板文件分为header和body两部分。允许用户自定义自己的模板文件。
+- FileHeader能够自动的监测创建新文件动作,自动的添加模板。
+- 不仅支持创建已经使用模板初始化好的文件,而且支持将header添加到已经存在的文件头部,并且支持批量添加。
+- 使用了非常强大并且很容易使用的 `Jinja2 `_ 模板系统,在模板文件里你可以完成很多复杂的初始化。
+- 几乎支持所有的编程语言,并且支持用户自定义语言。
+- 能够自动的更新文件最后修改时间。
+- 能够自动的更新文件最后的修改者,这在协同开发中是一个很有用的功能。
+- 支持ST2/ST3。
+
+安装
+------
+
+可以通过 **Package Control** 搜索 **FileHeader** 安装。
+
+或者:
+
+进入到你的"Packages"文件夹 **(Preferences / Browse Packages)** ,然后:
+
+.. code-block:: python
+
+ git clone git@github.com:shiyanhui/FileHeader.git
+
+使用
+------
+
+FileHeader非常容易使用。
+
+创建新文件
+`````````
+
+FileHeader能够自动的监测创建新文件动作,自动的添加模板。因此你可以用别的插件创建新文件,FileHeader会自动的给你添加模板。
+
+- Sidebar Menu
+
+ .. image:: https://raw.github.com/shiyanhui/shiyanhui.github.io/master/images/FileHeader/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**.
+
+
+添加文件头
+`````````
+
+- Sidebar Menu
+
+ .. image:: https://raw.github.com/shiyanhui/shiyanhui.github.io/master/images/FileHeader/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**.
+
+批量添加文件头
+`````````
+
+.. image:: https://raw.github.com/shiyanhui/shiyanhui.github.io/master/images/FileHeader/add-header-dir.gif
+
+
+自动更新文件修改时间和最后修改者
+`````````
+
+.. image:: https://raw.github.com/shiyanhui/shiyanhui.github.io/master/images/FileHeader/update.gif
+
+
+详细设置及文档请看 `GitHub `_ 。
\ No newline at end of file
diff --git a/doc/make.bat b/doc/make.bat
new file mode 100644
index 0000000..cafda5e
--- /dev/null
+++ b/doc/make.bat
@@ -0,0 +1,242 @@
+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+ set SPHINXBUILD=sphinx-build
+)
+set BUILDDIR=_build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
+set I18NSPHINXOPTS=%SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+ set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+ set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+ :help
+ echo.Please use `make ^` where ^ is one of
+ echo. html to make standalone HTML files
+ echo. dirhtml to make HTML files named index.html in directories
+ echo. singlehtml to make a single large HTML file
+ echo. pickle to make pickle files
+ echo. json to make JSON files
+ echo. htmlhelp to make HTML files and a HTML help project
+ echo. qthelp to make HTML files and a qthelp project
+ echo. devhelp to make HTML files and a Devhelp project
+ echo. epub to make an epub
+ echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+ echo. text to make text files
+ echo. man to make manual pages
+ echo. texinfo to make Texinfo files
+ echo. gettext to make PO message catalogs
+ echo. changes to make an overview over all changed/added/deprecated items
+ echo. xml to make Docutils-native XML files
+ echo. pseudoxml to make pseudoxml-XML files for display purposes
+ echo. linkcheck to check all external links for integrity
+ echo. doctest to run all doctests embedded in the documentation if enabled
+ goto end
+)
+
+if "%1" == "clean" (
+ for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+ del /q /s %BUILDDIR%\*
+ goto end
+)
+
+
+%SPHINXBUILD% 2> nul
+if errorlevel 9009 (
+ echo.
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
+ echo.installed, then set the SPHINXBUILD environment variable to point
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
+ echo.may add the Sphinx directory to PATH.
+ echo.
+ echo.If you don't have Sphinx installed, grab it from
+ echo.http://sphinx-doc.org/
+ exit /b 1
+)
+
+if "%1" == "html" (
+ %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+ goto end
+)
+
+if "%1" == "dirhtml" (
+ %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
+ goto end
+)
+
+if "%1" == "singlehtml" (
+ %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
+ goto end
+)
+
+if "%1" == "pickle" (
+ %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can process the pickle files.
+ goto end
+)
+
+if "%1" == "json" (
+ %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can process the JSON files.
+ goto end
+)
+
+if "%1" == "htmlhelp" (
+ %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in %BUILDDIR%/htmlhelp.
+ goto end
+)
+
+if "%1" == "qthelp" (
+ %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in %BUILDDIR%/qthelp, like this:
+ echo.^> qcollectiongenerator %BUILDDIR%\qthelp\FileHeader.qhcp
+ echo.To view the help file:
+ echo.^> assistant -collectionFile %BUILDDIR%\qthelp\FileHeader.ghc
+ goto end
+)
+
+if "%1" == "devhelp" (
+ %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished.
+ goto end
+)
+
+if "%1" == "epub" (
+ %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The epub file is in %BUILDDIR%/epub.
+ goto end
+)
+
+if "%1" == "latex" (
+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
+ goto end
+)
+
+if "%1" == "latexpdf" (
+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+ cd %BUILDDIR%/latex
+ make all-pdf
+ cd %BUILDDIR%/..
+ echo.
+ echo.Build finished; the PDF files are in %BUILDDIR%/latex.
+ goto end
+)
+
+if "%1" == "latexpdfja" (
+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+ cd %BUILDDIR%/latex
+ make all-pdf-ja
+ cd %BUILDDIR%/..
+ echo.
+ echo.Build finished; the PDF files are in %BUILDDIR%/latex.
+ goto end
+)
+
+if "%1" == "text" (
+ %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The text files are in %BUILDDIR%/text.
+ goto end
+)
+
+if "%1" == "man" (
+ %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The manual pages are in %BUILDDIR%/man.
+ goto end
+)
+
+if "%1" == "texinfo" (
+ %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
+ goto end
+)
+
+if "%1" == "gettext" (
+ %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
+ goto end
+)
+
+if "%1" == "changes" (
+ %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.The overview file is in %BUILDDIR%/changes.
+ goto end
+)
+
+if "%1" == "linkcheck" (
+ %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Link check complete; look for any errors in the above output ^
+or in %BUILDDIR%/linkcheck/output.txt.
+ goto end
+)
+
+if "%1" == "doctest" (
+ %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Testing of doctests in the sources finished, look at the ^
+results in %BUILDDIR%/doctest/output.txt.
+ goto end
+)
+
+if "%1" == "xml" (
+ %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The XML files are in %BUILDDIR%/xml.
+ goto end
+)
+
+if "%1" == "pseudoxml" (
+ %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
+ if errorlevel 1 exit /b 1
+ echo.
+ echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
+ goto end
+)
+
+:end
diff --git a/template/Language - English.tmpl b/template/Language - English.tmpl
deleted file mode 100644
index e69de29..0000000
diff --git a/template/Lisp.tmpl b/template/Lisp.tmpl
deleted file mode 100644
index e69de29..0000000
diff --git a/template/Objective-C.tmpl b/template/Objective-C.tmpl
deleted file mode 100644
index e69de29..0000000
diff --git a/template/Pascal.tmpl b/template/Pascal.tmpl
deleted file mode 100644
index e69de29..0000000
diff --git a/template/Python.tmpl b/template/Python.tmpl
deleted file mode 100644
index f607b7a..0000000
--- a/template/Python.tmpl
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# @Date : {{ date }}
-# @Author : {{ author }}
-
diff --git a/template/Rails.tmpl b/template/Rails.tmpl
deleted file mode 100644
index e69de29..0000000
diff --git a/template/Regular Expressions.tmpl b/template/Regular Expressions.tmpl
deleted file mode 100644
index e69de29..0000000
diff --git a/template/Scala.tmpl b/template/Scala.tmpl
deleted file mode 100644
index e69de29..0000000
diff --git a/template/Theme - Default.tmpl b/template/Theme - Default.tmpl
deleted file mode 100644
index e69de29..0000000
diff --git a/template/Vintage.tmpl b/template/Vintage.tmpl
deleted file mode 100644
index e69de29..0000000
diff --git a/template/body/ASP.tmpl b/template/body/ASP.tmpl
new file mode 100644
index 0000000..a852b08
--- /dev/null
+++ b/template/body/ASP.tmpl
@@ -0,0 +1,5 @@
+
+
+ <% Response.Write "" %>
+
+
diff --git a/template/body/ActionScript.tmpl b/template/body/ActionScript.tmpl
new file mode 100644
index 0000000..5d5db87
--- /dev/null
+++ b/template/body/ActionScript.tmpl
@@ -0,0 +1,8 @@
+package {
+ import flash.display.Sprite;
+ public class Main extends Sprite {
+ public function Main():void {
+
+ }
+ }
+}
diff --git a/template/AppleScript.tmpl b/template/body/AppleScript.tmpl
similarity index 100%
rename from template/AppleScript.tmpl
rename to template/body/AppleScript.tmpl
diff --git a/template/Batch File.tmpl b/template/body/Batch File.tmpl
similarity index 100%
rename from template/Batch File.tmpl
rename to template/body/Batch File.tmpl
diff --git a/template/body/C#.tmpl b/template/body/C#.tmpl
new file mode 100644
index 0000000..50fc130
--- /dev/null
+++ b/template/body/C#.tmpl
@@ -0,0 +1,5 @@
+class MainClass {
+ static void Main() {
+
+ }
+}
diff --git a/template/body/C++.tmpl b/template/body/C++.tmpl
new file mode 100644
index 0000000..e936e99
--- /dev/null
+++ b/template/body/C++.tmpl
@@ -0,0 +1,8 @@
+#include
+
+using namespace std;
+
+int main(){
+
+ return 0;
+}
diff --git a/template/body/C.tmpl b/template/body/C.tmpl
new file mode 100644
index 0000000..32d1af6
--- /dev/null
+++ b/template/body/C.tmpl
@@ -0,0 +1,6 @@
+#include
+
+int main() {
+
+ return 0;
+}
diff --git a/template/CSS.tmpl b/template/body/CSS.tmpl
similarity index 100%
rename from template/CSS.tmpl
rename to template/body/CSS.tmpl
diff --git a/template/Clojure.tmpl b/template/body/Clojure.tmpl
similarity index 100%
rename from template/Clojure.tmpl
rename to template/body/Clojure.tmpl
diff --git a/template/body/D.tmpl b/template/body/D.tmpl
new file mode 100644
index 0000000..5b33c8c
--- /dev/null
+++ b/template/body/D.tmpl
@@ -0,0 +1,5 @@
+import std.stdio;
+
+void main(){
+
+}
diff --git a/template/Diff.tmpl b/template/body/Diff.tmpl
similarity index 100%
rename from template/Diff.tmpl
rename to template/body/Diff.tmpl
diff --git a/template/body/Erlang.tmpl b/template/body/Erlang.tmpl
new file mode 100644
index 0000000..8ab6530
--- /dev/null
+++ b/template/body/Erlang.tmpl
@@ -0,0 +1,5 @@
+-module(erlang_hw).
+-export([start/0]).
+
+start() ->
+ io:format("").
diff --git a/template/body/Go.tmpl b/template/body/Go.tmpl
new file mode 100644
index 0000000..140a5e1
--- /dev/null
+++ b/template/body/Go.tmpl
@@ -0,0 +1,7 @@
+package main
+
+import "fmt"
+
+func main() {
+
+}
diff --git a/template/Graphviz.tmpl b/template/body/Graphviz.tmpl
similarity index 100%
rename from template/Graphviz.tmpl
rename to template/body/Graphviz.tmpl
diff --git a/template/Groovy.tmpl b/template/body/Groovy.tmpl
similarity index 100%
rename from template/Groovy.tmpl
rename to template/body/Groovy.tmpl
diff --git a/template/body/HTML.tmpl b/template/body/HTML.tmpl
new file mode 100644
index 0000000..7b05adc
--- /dev/null
+++ b/template/body/HTML.tmpl
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/template/body/Haskell.tmpl b/template/body/Haskell.tmpl
new file mode 100644
index 0000000..8b9737b
--- /dev/null
+++ b/template/body/Haskell.tmpl
@@ -0,0 +1,2 @@
+module Main
+ where
diff --git a/template/body/Java.tmpl b/template/body/Java.tmpl
new file mode 100644
index 0000000..22603fc
--- /dev/null
+++ b/template/body/Java.tmpl
@@ -0,0 +1,5 @@
+public class java {
+ public static void main(String[] args) {
+
+ }
+}
diff --git a/template/body/JavaScript.tmpl b/template/body/JavaScript.tmpl
new file mode 100644
index 0000000..ad9a93a
--- /dev/null
+++ b/template/body/JavaScript.tmpl
@@ -0,0 +1 @@
+'use strict';
diff --git a/template/body/LaTeX.tmpl b/template/body/LaTeX.tmpl
new file mode 100644
index 0000000..94ae1a3
--- /dev/null
+++ b/template/body/LaTeX.tmpl
@@ -0,0 +1,4 @@
+\documentclass{article}
+\begin{document}
+
+\end{document}
diff --git a/template/body/Lisp.tmpl b/template/body/Lisp.tmpl
new file mode 100644
index 0000000..9026966
--- /dev/null
+++ b/template/body/Lisp.tmpl
@@ -0,0 +1,3 @@
+(DEFUN MAIN ()
+
+)
diff --git a/template/Lua.tmpl b/template/body/Lua.tmpl
similarity index 100%
rename from template/Lua.tmpl
rename to template/body/Lua.tmpl
diff --git a/template/Makefile.tmpl b/template/body/Makefile.tmpl
similarity index 100%
rename from template/Makefile.tmpl
rename to template/body/Makefile.tmpl
diff --git a/template/Markdown.tmpl b/template/body/Markdown.tmpl
similarity index 100%
rename from template/Markdown.tmpl
rename to template/body/Markdown.tmpl
diff --git a/template/Matlab.tmpl b/template/body/Matlab.tmpl
similarity index 100%
rename from template/Matlab.tmpl
rename to template/body/Matlab.tmpl
diff --git a/template/OCaml.tmpl b/template/body/OCaml.tmpl
similarity index 100%
rename from template/OCaml.tmpl
rename to template/body/OCaml.tmpl
diff --git a/template/body/Objective-C.tmpl b/template/body/Objective-C.tmpl
new file mode 100644
index 0000000..cf27186
--- /dev/null
+++ b/template/body/Objective-C.tmpl
@@ -0,0 +1,6 @@
+#import
+
+int main(int argc, char *argv[]) {
+
+ return 0;
+}
diff --git a/template/PHP.tmpl b/template/body/PHP.tmpl
similarity index 100%
rename from template/PHP.tmpl
rename to template/body/PHP.tmpl
diff --git a/template/body/Pascal.tmpl b/template/body/Pascal.tmpl
new file mode 100644
index 0000000..ea91d13
--- /dev/null
+++ b/template/body/Pascal.tmpl
@@ -0,0 +1,4 @@
+program Main(output);
+begin
+
+end.
diff --git a/template/Perl.tmpl b/template/body/Perl.tmpl
similarity index 100%
rename from template/Perl.tmpl
rename to template/body/Perl.tmpl
diff --git a/template/ASP.tmpl b/template/body/Python.tmpl
similarity index 100%
rename from template/ASP.tmpl
rename to template/body/Python.tmpl
diff --git a/template/R.tmpl b/template/body/R.tmpl
similarity index 100%
rename from template/R.tmpl
rename to template/body/R.tmpl
diff --git a/template/RestructuredText.tmpl b/template/body/RestructuredText.tmpl
similarity index 100%
rename from template/RestructuredText.tmpl
rename to template/body/RestructuredText.tmpl
diff --git a/template/Ruby.tmpl b/template/body/Ruby.tmpl
similarity index 100%
rename from template/Ruby.tmpl
rename to template/body/Ruby.tmpl
diff --git a/template/SQL.tmpl b/template/body/SQL.tmpl
similarity index 100%
rename from template/SQL.tmpl
rename to template/body/SQL.tmpl
diff --git a/template/body/Scala.tmpl b/template/body/Scala.tmpl
new file mode 100644
index 0000000..0ff9456
--- /dev/null
+++ b/template/body/Scala.tmpl
@@ -0,0 +1,3 @@
+object Main extends Application {
+
+}
diff --git a/template/ShellScript.tmpl b/template/body/ShellScript.tmpl
similarity index 100%
rename from template/ShellScript.tmpl
rename to template/body/ShellScript.tmpl
diff --git a/template/TCL.tmpl b/template/body/TCL.tmpl
similarity index 100%
rename from template/TCL.tmpl
rename to template/body/TCL.tmpl
diff --git a/template/Text.tmpl b/template/body/Text.tmpl
similarity index 100%
rename from template/Text.tmpl
rename to template/body/Text.tmpl
diff --git a/template/Textile.tmpl b/template/body/Textile.tmpl
similarity index 100%
rename from template/Textile.tmpl
rename to template/body/Textile.tmpl
diff --git a/template/XML.tmpl b/template/body/XML.tmpl
similarity index 100%
rename from template/XML.tmpl
rename to template/body/XML.tmpl
diff --git a/template/YAML.tmpl b/template/body/YAML.tmpl
similarity index 100%
rename from template/YAML.tmpl
rename to template/body/YAML.tmpl
diff --git a/template/ActionScript.tmpl b/template/header/ASP.tmpl
similarity index 100%
rename from template/ActionScript.tmpl
rename to template/header/ASP.tmpl
diff --git a/template/header/ActionScript.tmpl b/template/header/ActionScript.tmpl
new file mode 100644
index 0000000..8dcb519
--- /dev/null
+++ b/template/header/ActionScript.tmpl
@@ -0,0 +1,7 @@
+/*
+* @Author: {{author}}
+* @Date: {{create_time}}
+* @Last Modified by: {{last_modified_by}}
+* @Last Modified time: {{last_modified_time}}
+*/
+
diff --git a/template/header/AppleScript.tmpl b/template/header/AppleScript.tmpl
new file mode 100644
index 0000000..4ce6a65
--- /dev/null
+++ b/template/header/AppleScript.tmpl
@@ -0,0 +1,7 @@
+(*
+* @Author: {{author}}
+* @Date: {{create_time}}
+* @Last Modified by: {{last_modified_by}}
+* @Last Modified time: {{last_modified_time}}
+*)
+
diff --git a/template/header/Batch File.tmpl b/template/header/Batch File.tmpl
new file mode 100644
index 0000000..d3af71f
--- /dev/null
+++ b/template/header/Batch File.tmpl
@@ -0,0 +1,5 @@
+@REM @Author: {{author}}
+@REM @Date: {{create_time}}
+@REM @Last Modified by: {{last_modified_by}}
+@REM Modified time: {{last_modified_time}}
+
diff --git a/template/header/C#.tmpl b/template/header/C#.tmpl
new file mode 100644
index 0000000..8dcb519
--- /dev/null
+++ b/template/header/C#.tmpl
@@ -0,0 +1,7 @@
+/*
+* @Author: {{author}}
+* @Date: {{create_time}}
+* @Last Modified by: {{last_modified_by}}
+* @Last Modified time: {{last_modified_time}}
+*/
+
diff --git a/template/header/C++.tmpl b/template/header/C++.tmpl
new file mode 100644
index 0000000..8dcb519
--- /dev/null
+++ b/template/header/C++.tmpl
@@ -0,0 +1,7 @@
+/*
+* @Author: {{author}}
+* @Date: {{create_time}}
+* @Last Modified by: {{last_modified_by}}
+* @Last Modified time: {{last_modified_time}}
+*/
+
diff --git a/template/header/C.tmpl b/template/header/C.tmpl
new file mode 100644
index 0000000..8dcb519
--- /dev/null
+++ b/template/header/C.tmpl
@@ -0,0 +1,7 @@
+/*
+* @Author: {{author}}
+* @Date: {{create_time}}
+* @Last Modified by: {{last_modified_by}}
+* @Last Modified time: {{last_modified_time}}
+*/
+
diff --git a/template/header/CSS.tmpl b/template/header/CSS.tmpl
new file mode 100644
index 0000000..8dcb519
--- /dev/null
+++ b/template/header/CSS.tmpl
@@ -0,0 +1,7 @@
+/*
+* @Author: {{author}}
+* @Date: {{create_time}}
+* @Last Modified by: {{last_modified_by}}
+* @Last Modified time: {{last_modified_time}}
+*/
+
diff --git a/template/header/Clojure.tmpl b/template/header/Clojure.tmpl
new file mode 100644
index 0000000..635fa4a
--- /dev/null
+++ b/template/header/Clojure.tmpl
@@ -0,0 +1,5 @@
+; @Author: {{author}}
+; @Date: {{create_time}}
+; @Last Modified by: {{last_modified_by}}
+; @Last Modified time: {{last_modified_time}}
+
diff --git a/template/header/D.tmpl b/template/header/D.tmpl
new file mode 100644
index 0000000..8dcb519
--- /dev/null
+++ b/template/header/D.tmpl
@@ -0,0 +1,7 @@
+/*
+* @Author: {{author}}
+* @Date: {{create_time}}
+* @Last Modified by: {{last_modified_by}}
+* @Last Modified time: {{last_modified_time}}
+*/
+
diff --git a/template/C#.tmpl b/template/header/Diff.tmpl
similarity index 100%
rename from template/C#.tmpl
rename to template/header/Diff.tmpl
diff --git a/template/header/Erlang.tmpl b/template/header/Erlang.tmpl
new file mode 100644
index 0000000..5a0189f
--- /dev/null
+++ b/template/header/Erlang.tmpl
@@ -0,0 +1,5 @@
+% @Author: {{author}}
+% @Date: {{create_time}}
+% @Last Modified by: {{last_modified_by}}
+% @Last Modified time: {{last_modified_time}}
+
diff --git a/template/header/Go.tmpl b/template/header/Go.tmpl
new file mode 100644
index 0000000..8dcb519
--- /dev/null
+++ b/template/header/Go.tmpl
@@ -0,0 +1,7 @@
+/*
+* @Author: {{author}}
+* @Date: {{create_time}}
+* @Last Modified by: {{last_modified_by}}
+* @Last Modified time: {{last_modified_time}}
+*/
+
diff --git a/template/C++.tmpl b/template/header/Graphviz.tmpl
similarity index 100%
rename from template/C++.tmpl
rename to template/header/Graphviz.tmpl
diff --git a/template/Color Scheme - Default.tmpl b/template/header/Groovy.tmpl
similarity index 100%
rename from template/Color Scheme - Default.tmpl
rename to template/header/Groovy.tmpl
diff --git a/template/HTML.tmpl b/template/header/HTML.tmpl
similarity index 100%
rename from template/HTML.tmpl
rename to template/header/HTML.tmpl
diff --git a/template/header/Haskell.tmpl b/template/header/Haskell.tmpl
new file mode 100644
index 0000000..eb114ce
--- /dev/null
+++ b/template/header/Haskell.tmpl
@@ -0,0 +1,5 @@
+-- @Author: {{author}}
+-- @Date: {{create_time}}
+-- @Last Modified by: {{last_modified_by}}
+-- @Last Modified time: {{last_modified_time}}
+
diff --git a/template/header/Java.tmpl b/template/header/Java.tmpl
new file mode 100644
index 0000000..8dcb519
--- /dev/null
+++ b/template/header/Java.tmpl
@@ -0,0 +1,7 @@
+/*
+* @Author: {{author}}
+* @Date: {{create_time}}
+* @Last Modified by: {{last_modified_by}}
+* @Last Modified time: {{last_modified_time}}
+*/
+
diff --git a/template/header/JavaScript.tmpl b/template/header/JavaScript.tmpl
new file mode 100644
index 0000000..8dcb519
--- /dev/null
+++ b/template/header/JavaScript.tmpl
@@ -0,0 +1,7 @@
+/*
+* @Author: {{author}}
+* @Date: {{create_time}}
+* @Last Modified by: {{last_modified_by}}
+* @Last Modified time: {{last_modified_time}}
+*/
+
diff --git a/template/header/LaTeX.tmpl b/template/header/LaTeX.tmpl
new file mode 100644
index 0000000..5a0189f
--- /dev/null
+++ b/template/header/LaTeX.tmpl
@@ -0,0 +1,5 @@
+% @Author: {{author}}
+% @Date: {{create_time}}
+% @Last Modified by: {{last_modified_by}}
+% @Last Modified time: {{last_modified_time}}
+
diff --git a/template/header/Lisp.tmpl b/template/header/Lisp.tmpl
new file mode 100644
index 0000000..4c60151
--- /dev/null
+++ b/template/header/Lisp.tmpl
@@ -0,0 +1,5 @@
+;;;; @Author: {{author}}
+;;;; @Date: {{create_time}}
+;;;; @Last Modified by: {{last_modified_by}}
+;;;; @Last Modified time: {{last_modified_time}}
+
diff --git a/template/header/Lua.tmpl b/template/header/Lua.tmpl
new file mode 100644
index 0000000..eb114ce
--- /dev/null
+++ b/template/header/Lua.tmpl
@@ -0,0 +1,5 @@
+-- @Author: {{author}}
+-- @Date: {{create_time}}
+-- @Last Modified by: {{last_modified_by}}
+-- @Last Modified time: {{last_modified_time}}
+
diff --git a/template/D.tmpl b/template/header/Makefile.tmpl
similarity index 100%
rename from template/D.tmpl
rename to template/header/Makefile.tmpl
diff --git a/template/Default.tmpl b/template/header/Markdown.tmpl
similarity index 100%
rename from template/Default.tmpl
rename to template/header/Markdown.tmpl
diff --git a/template/header/Matlab.tmpl b/template/header/Matlab.tmpl
new file mode 100644
index 0000000..5a0189f
--- /dev/null
+++ b/template/header/Matlab.tmpl
@@ -0,0 +1,5 @@
+% @Author: {{author}}
+% @Date: {{create_time}}
+% @Last Modified by: {{last_modified_by}}
+% @Last Modified time: {{last_modified_time}}
+
diff --git a/template/header/OCaml.tmpl b/template/header/OCaml.tmpl
new file mode 100644
index 0000000..4ce6a65
--- /dev/null
+++ b/template/header/OCaml.tmpl
@@ -0,0 +1,7 @@
+(*
+* @Author: {{author}}
+* @Date: {{create_time}}
+* @Last Modified by: {{last_modified_by}}
+* @Last Modified time: {{last_modified_time}}
+*)
+
diff --git a/template/header/Objective-C.tmpl b/template/header/Objective-C.tmpl
new file mode 100644
index 0000000..8dcb519
--- /dev/null
+++ b/template/header/Objective-C.tmpl
@@ -0,0 +1,7 @@
+/*
+* @Author: {{author}}
+* @Date: {{create_time}}
+* @Last Modified by: {{last_modified_by}}
+* @Last Modified time: {{last_modified_time}}
+*/
+
diff --git a/template/header/PHP.tmpl b/template/header/PHP.tmpl
new file mode 100644
index 0000000..d6467fd
--- /dev/null
+++ b/template/header/PHP.tmpl
@@ -0,0 +1,7 @@
+/**
+ * @Author: {{author}}
+ * @Date: {{create_time}}
+ * @Last Modified by: {{last_modified_by}}
+ * @Last Modified time: {{last_modified_time}}
+ */
+
diff --git a/template/header/Pascal.tmpl b/template/header/Pascal.tmpl
new file mode 100644
index 0000000..4ce6a65
--- /dev/null
+++ b/template/header/Pascal.tmpl
@@ -0,0 +1,7 @@
+(*
+* @Author: {{author}}
+* @Date: {{create_time}}
+* @Last Modified by: {{last_modified_by}}
+* @Last Modified time: {{last_modified_time}}
+*)
+
diff --git a/template/header/Perl.tmpl b/template/header/Perl.tmpl
new file mode 100644
index 0000000..5b4917b
--- /dev/null
+++ b/template/header/Perl.tmpl
@@ -0,0 +1,5 @@
+# @Author: {{author}}
+# @Date: {{create_time}}
+# @Last Modified by: {{last_modified_by}}
+# @Last Modified time: {{last_modified_time}}
+
diff --git a/template/header/Python.tmpl b/template/header/Python.tmpl
new file mode 100644
index 0000000..1c3e015
--- /dev/null
+++ b/template/header/Python.tmpl
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+# @Author: {{author}}
+# @Date: {{create_time}}
+# @Last Modified by: {{last_modified_by}}
+# @Last Modified time: {{last_modified_time}}
+
diff --git a/template/Erlang.tmpl b/template/header/R.tmpl
similarity index 100%
rename from template/Erlang.tmpl
rename to template/header/R.tmpl
diff --git a/template/Go.tmpl b/template/header/RestructuredText.tmpl
similarity index 100%
rename from template/Go.tmpl
rename to template/header/RestructuredText.tmpl
diff --git a/template/header/Ruby.tmpl b/template/header/Ruby.tmpl
new file mode 100644
index 0000000..62ab9f7
--- /dev/null
+++ b/template/header/Ruby.tmpl
@@ -0,0 +1,6 @@
+#!/usr/bin/ruby
+# @Author: {{author}}
+# @Date: {{create_time}}
+# @Last Modified by: {{last_modified_by}}
+# @Last Modified time: {{last_modified_time}}
+
diff --git a/template/header/SCSS.tmpl b/template/header/SCSS.tmpl
new file mode 100644
index 0000000..8dcb519
--- /dev/null
+++ b/template/header/SCSS.tmpl
@@ -0,0 +1,7 @@
+/*
+* @Author: {{author}}
+* @Date: {{create_time}}
+* @Last Modified by: {{last_modified_by}}
+* @Last Modified time: {{last_modified_time}}
+*/
+
diff --git a/template/header/SQL.tmpl b/template/header/SQL.tmpl
new file mode 100644
index 0000000..8dcb519
--- /dev/null
+++ b/template/header/SQL.tmpl
@@ -0,0 +1,7 @@
+/*
+* @Author: {{author}}
+* @Date: {{create_time}}
+* @Last Modified by: {{last_modified_by}}
+* @Last Modified time: {{last_modified_time}}
+*/
+
diff --git a/template/header/Scala.tmpl b/template/header/Scala.tmpl
new file mode 100644
index 0000000..8dcb519
--- /dev/null
+++ b/template/header/Scala.tmpl
@@ -0,0 +1,7 @@
+/*
+* @Author: {{author}}
+* @Date: {{create_time}}
+* @Last Modified by: {{last_modified_by}}
+* @Last Modified time: {{last_modified_time}}
+*/
+
diff --git a/template/header/ShellScript.tmpl b/template/header/ShellScript.tmpl
new file mode 100644
index 0000000..5b4917b
--- /dev/null
+++ b/template/header/ShellScript.tmpl
@@ -0,0 +1,5 @@
+# @Author: {{author}}
+# @Date: {{create_time}}
+# @Last Modified by: {{last_modified_by}}
+# @Last Modified time: {{last_modified_time}}
+
diff --git a/template/header/TCL.tmpl b/template/header/TCL.tmpl
new file mode 100644
index 0000000..5b4917b
--- /dev/null
+++ b/template/header/TCL.tmpl
@@ -0,0 +1,5 @@
+# @Author: {{author}}
+# @Date: {{create_time}}
+# @Last Modified by: {{last_modified_by}}
+# @Last Modified time: {{last_modified_time}}
+
diff --git a/template/Haskell.tmpl b/template/header/Text.tmpl
similarity index 100%
rename from template/Haskell.tmpl
rename to template/header/Text.tmpl
diff --git a/template/Java.tmpl b/template/header/Textile.tmpl
similarity index 100%
rename from template/Java.tmpl
rename to template/header/Textile.tmpl
diff --git a/template/JavaScript.tmpl b/template/header/XML.tmpl
similarity index 100%
rename from template/JavaScript.tmpl
rename to template/header/XML.tmpl
diff --git a/template/LaTeX.tmpl b/template/header/YAML.tmpl
similarity index 100%
rename from template/LaTeX.tmpl
rename to template/header/YAML.tmpl