templatefile-1.5/000075500000000000000000000000001065433672000140365ustar00rootroot00000000000000templatefile-1.5/vim/000075500000000000000000000000001065433672000146315ustar00rootroot00000000000000templatefile-1.5/vim/plugin/000075500000000000000000000000001065433672000161275ustar00rootroot00000000000000templatefile-1.5/vim/plugin/templatefile.vim000064400000000000000000000101301065433672000213120ustar00rootroot00000000000000"============================================================================= " Vim global plugin for autoload template files " File: templatefile.vim " Maintainer: Lubomir Host " Last Change: 2002/02/05 " Version: $Id: templatefile.vim,v 1.3 2002/02/06 01:13:40 host8 Exp $ " Thanks: " Scott Urban : First version of templatefile.vim " http://vim.sourceforge.net/scripts/ " script.php?script_id=198 " " Description: " Plugin load template file for new files " Templates for new files aren't loaded, if g:load_templates == "no" " if g:load_templates == "ask" you are asked before loading template " If exists enviroment variable $VIMTEMPLATE, templates are loaded from " this directory. augroup TemplateSystem autocmd! au BufNewFile * call LoadTemplateFile() augroup END command! -nargs=0 LoadTemplateFile call LoadTemplateFile() command! -nargs=1 LoadFile call LoadFile() " template file loaded fun! LoadTemplateFile() if exists("g:load_templates") if g:load_templates == "no" return endif endif let extension = expand ("%:e") if extension == "" let template_file = "templates/" . expand("%:t") let template_func = "TemplateFileFunc_noext_" . expand("%:t") else let template_file = "templates/skel." . extension let template_func = "TemplateFileFunc_" . extension endif if filereadable(expand($VIMTEMPLATE . template_file)) call LoadTemplateFileConfirm($VIMTEMPLATE . template_file) elseif filereadable(expand($HOME . "/.vim/" . template_file)) call LoadTemplateFileConfirm($HOME . "/.vim/" . template_file) elseif filereadable(expand($VIM . template_file)) call LoadTemplateFileConfirm($VIM . template_file) elseif filereadable(expand($VIMRUNTIME . template_file)) call LoadTemplateFileConfirm($VIMRUNTIME . template_file) else " Template not found endif let date = strftime("%c") let year = strftime("%Y") let cwd = getcwd() let lastdir = substitute(cwd, ".*/", "", "g") let myfile = expand("%:t:r") let myfile_ext = expand("%") let inc_gaurd = substitute(myfile, "\\.", "_", "g") let inc_gaurd = toupper(inc_gaurd) silent! execute "%s/@DATE@/" . date . "/g" silent! execute "%s/@YEAR@/" . year . "/g" silent! execute "%s/@LASTDIR@/" . lastdir . "/g" silent! execute "%s/@FILE@/" . myfile . "/g" silent! execute "%s/@FILE_EXT@/" . myfile_ext . "/g" silent! execute "%s/@INCLUDE_GAURD@/" . inc_gaurd . "/g" if exists ("*" . template_func) if exists("g:load_templates") if g:load_templates == "ask" let choice = confirm("Call function " . template_func . "() ?:", \ "&yes\n" . \ "&no\n") if choice == 1 silent! execute ":call " . template_func . "()" endif elseif g:load_templates == "yes" silent! execute ":call " . template_func . "()" endif else silent! execute ":call " . template_func . "()" endif endif endfun fun! LoadTemplateFileConfirm(filename) if filereadable(expand(a:filename)) if exists("g:load_templates") if g:load_templates == "ask" let choice = confirm("NEW FILE! Load template file " . \ expand(a:filename) . " ?:", \ "&yes\n" . \ "&no\n") if choice == 1 execute "0r " . a:filename endif elseif g:load_templates == "yes" execute "0r " . a:filename endif else execute "0r " . a:filename endif endif endfun fun! LoadFile(filename) if filereadable(expand(a:filename)) if exists("g:load_templates") if g:load_templates == "ask" let choice = confirm("Load file " . \ expand(a:filename) . " ?:", \ "&yes\n" . \ "&no\n") if choice == 1 execute "0r " . a:filename endif elseif g:load_templates == "yes" execute "0r " . a:filename endif else execute "0r " . a:filename endif else echo "File not found!" endif endfun " example for no-extension file specific template processing fun! TemplateFileFunc_noext_makefile() let save_r = @r let @r = "all:\n\techo your template files need work" normal G put r let @r = save_r endfun " Modeline {{{ " vim:set ts=4: " vim600:fdm=marker fdl=0 fdc=3 vb t_vb=: " }}} templatefile-1.5/vim/templates/000075500000000000000000000000001065433672000166275ustar00rootroot00000000000000templatefile-1.5/vim/templates/Makefile000064400000000000000000000023711065433672000202720ustar00rootroot00000000000000# Makefile for creating distribution # Type 'make dist' for create tar-gziped archiv. # # Author: Lubomir Host 'rajo' /dev/null \ || cp -p $$d/$$file $(distdir)/$$file || :; \ fi; \ done templatefile-1.5/vim/templates/skel.c000064400000000000000000000003761065433672000177370ustar00rootroot00000000000000/* * $Id$ */ #include #include "@FILE@.h" /* Function int main(int argc, char **argv) {{{ */ int main(int argc, char **argv) { return 0; } /* }}} */ /* Modeline for ViM {{{ * vim:set ts=4: * vim600:fdm=marker fdl=0 fdc=3: * }}} */ templatefile-1.5/vim/templates/skel.h000064400000000000000000000001551065433672000177370ustar00rootroot00000000000000/* * $Id$ */ #ifndef @INCLUDE_GAURD@_H # define @INCLUDE_GAURD@_H #endif /* ifndef @INCLUDE_GAURD@_H */ templatefile-1.5/vim/templates/skel.sh000064400000000000000000000000271065433672000201200ustar00rootroot00000000000000#!/bin/bash # $Id: $