sponsor Vim development Vim logo Vim Book Ad

QuickTemplate : create new files from existing templates on-the-fly

 script karma  Rating 11/9, Downloaded by 562  Comments, bugs, improvements  Vim wiki

created by
ming cheng
 
script type
utility
 
description
create new files from existing templates on-the-fly
 
install details
download the source code, extract it to the directory. Reboot vim, input

:NewTemplate xhtml

to create XHTML template. there is another command for vim above 7.0:

:NewTemplateTab xhtml

by using this command you can create file in new tab. Of course, you can define key mapping to create
common types of files, for instance,

map nn :NewTemplateTab xhtml<cr>

press n twice under normal mode to create xhtml file in new tab.

the directory for this plugin is:

$VIMRUNTIME/plugin/Template.vim

and it has two default configure options

let g:TemplatePath=$VIM.'/vimfiles/template/'
let g:TemplateCursorFlag='#cursor#'

Among the 2 options, g:TemplatePath is the path for the templates, whereas the g:TemplatePathCursorFlag is the position for the mouse cursor to be moved to when the new template is built( moving to the bottom of the file by default).

Adding templates

Creating new template is supported by the script. First, find the path for the xhtml.tpl in g:TemplatePath. Then read the following content,

<html>
...
    <body>
        #cursor#
    </body>
</html>

it is easy to understand. If you are to build a python template, you can create python.tpl in g:TemplatePath and add the #cursor# in the appropriate position.

Please do not hesitate to throw your comments and suggestions here: http://www.gracecode.com/Archive/Display/2414
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
_vim_Template_20081008.7z 0.1 2008-10-08 6.0 ming cheng Initial upload
ip used for rating: 3.139.81.58

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github