Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Simple and flexible template engine.
Branch: master

Version 0.3.0

- autoloadize.
  - Added template#load().
  - Added template#search().
  - Added template#loading().
- Added [line] support to :Templateload.
- Use <nomodeline> if possible.
latest commit 7c3207164c
thinca authored committed
Failed to load latest commit information.
autoload Version 0.3.0
doc Version 0.3.0
plugin Version 0.3.0
README Version 0.3.0


This is a mirror of

*template* is a Vim plugin to read the template file automatically when the
edit of the file is newly started.  Template file is selected to match the
file name to open. Also, you can run any command after the open.

If the template files are located as follows:

 |-- doc
 |   `-- template.txt
 |-- plugin
 |   `-- template.vim
 |-- template.rb
 |-- template.vim
 |-- template_spec.rb

Template is loaded as follows.

Open file                       Template that is loaded
---------                       -----------------------
foo.vim                         template.vim
plugin/foo.vim                  plugin/template.vim                        
foo.rb                          template.rb
foo_spec.rb                     template_spec.rb
foo.txt                         (None)
doc/foo.txt                     doc/template.txt

And, you can execute commands when template loaded.

Defines replacing keywords:
    autocmd User plugin-template-loaded call s:template_keywords()
    function! s:template_keywords()
      %s/<+FILE NAME+>/\=expand('%:t')/g
      " And more...

Evaluate by vim and expand the inside of <%= %>:
    autocmd User plugin-template-loaded
    \ silent %s/<%=\(.\{-}\)%>/\=eval(submatch(1))/ge

Expand the date it is written in the following template.
    <%= strftime('%Y-%m-%d') %>

Move the cursor to <+CURSOR+>:
    autocmd User plugin-template-loaded
    \    if search('<+CURSOR+>')
    \  |   execute 'normal! "_da>'
    \  | endif

Filtered by an external command:
    autocmd User plugin-template-loaded silent! :%!erb
    autocmd User plugin-template-loaded silent! :%!php

Latest Version:
Something went wrong with that request. Please try again.