A vim plugin for creating file from template.SimplateTemplate can set filetype by the postfix of template file.And if there is no postfix the filetype will be setted as 'vim'.
Create a new file in current window
:SimpleTemplate template.php
Create a new file in new tab
:SimpleTemplateTab template.php
You can define a global variable for configuration.The variable name must be 'g:SimpleTemplate'.
let g:SimplateTemplate = {
"template path
\'path':'~/template/',
\'default_name':'noname',
\'cursor':'#cursor#',
\'flags':[
\{
\'key':'#author#',
\'value':'wondger'
\},
\{
\'key':'#date#',
\'value':'#date#'
\}
\]
\}
Default template path is $HOME/.vim/template/ in unix,and $VIM/vimfiles/template/ in others.
There are two system values you can use:
- #date# - current date time
- #filename# - file name
The keys in flags will be replaced by the value when load template file.
template file
/* * @name : Super Man * @author : __author__ * @crate : __date__ */ #cursor#
config
let g:SimplateTemplate = {
"template path
\'path':'~/template/',
\'default_name':'noname',
\'cursor':'#cursor#',
\'flags':[
\{
\'key':'__author__',
\'value':'wondger'
\},
\{
\'key':'__date__',
\'value':'#date#'
\}
\]
\}
excute command:
:SimpleTemplateTab template.js
Will create a file in new tab.And it's content is:
/* * @name : Super Man * @author : wondger * @crate : 2012-04-10 */ (cursor will move here)