Skip to content

wondger/SimpleTemplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 

Repository files navigation

SimpleTemplate

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

Usage

Create a new file in current window

:SimpleTemplate template.php

Create a new file in new tab

:SimpleTemplateTab template.php

Config

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.

Example

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)

About

a vim plugin for creating file from template

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published