Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for vimconfig/vim/plugin/templatefile.vim between version 1.1 and 1.2

version 1.1, 2002/02/05 22:41:54 version 1.2, 2002/02/06 00:43:23
Line 8 
Line 8 
 "               Scott Urban       : First version of templatefile.vim  "               Scott Urban       : First version of templatefile.vim
 "                                   http://vim.sourceforge.net/scripts/  "                                   http://vim.sourceforge.net/scripts/
 "                                          script.php?script_id=198  "                                          script.php?script_id=198
   "
   
 " Description:  " Description:
 "               load template file for new files  "               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  augroup TemplateSystem
         autocmd!          autocmd!
         au BufNewFile * silent call LoadTemplateFile()          au BufNewFile * call LoadTemplateFile()
 augroup END  augroup END
   
   
 " template file loaded  " template file loaded
 fun! LoadTemplateFile()  fun! LoadTemplateFile()
           if exists("g:load_templates")
                   if g:load_templates == "no"
                           return
                   endif
           endif
         let extension = expand ("%:e")          let extension = expand ("%:e")
         if extension == ""          if extension == ""
                 let template_file = "templates/" . expand("%:t")                  let template_file = "templates/" . expand("%:t")
Line 30  fun! LoadTemplateFile()
Line 38  fun! LoadTemplateFile()
                 let template_func = "TemplateFileFunc_" . extension                  let template_func = "TemplateFileFunc_" . extension
         endif          endif
         if filereadable(expand($VIMTEMPLATE . template_file))          if filereadable(expand($VIMTEMPLATE . template_file))
                 execute "0r "  $VIMTEMPLATE . template_file                  call LoadTemplateFileConfirm($VIMTEMPLATE . template_file)
         elseif filereadable(expand($HOME . "/.vim/" . template_file))          elseif filereadable(expand($HOME . "/.vim/" . template_file))
                 execute "0r " $HOME . "/.vim/" . template_file                  call LoadTemplateFileConfirm($HOME . "/.vim/" . template_file)
         elseif filereadable(expand($VIM . template_file))          elseif filereadable(expand($VIM . template_file))
                 execute "0r " $VIM . template_file                  call LoadTemplateFileConfirm($VIM . template_file)
         elseif filereadable(expand($VIMRUNTIME . template_file))          elseif filereadable(expand($VIMRUNTIME . template_file))
                 execute "0r " $VIMRUNTIME . template_file                  call LoadTemplateFileConfirm($VIMRUNTIME . template_file)
         else          else
                 " Template not found                  " Template not found
         endif          endif
Line 56  fun! LoadTemplateFile()
Line 64  fun! LoadTemplateFile()
         silent! execute "%s/@FILE_EXT@/" .  myfile_ext . "/g"          silent! execute "%s/@FILE_EXT@/" .  myfile_ext . "/g"
         silent! execute "%s/@INCLUDE_GAURD@/" . inc_gaurd . "/g"          silent! execute "%s/@INCLUDE_GAURD@/" . inc_gaurd . "/g"
         if exists ("*" . template_func)          if exists ("*" . template_func)
                 " echo "calling " . template_func                  if exists("g:load_templates")
                 " exec(":call " . template_func . "()")                          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(a:filename)
                   if exists("g:load_templates")
                           if g:load_templates == "ask"
                                   let choice = confirm("NEW FILE! Load template file?:",
                                                           \ "&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          endif
 endfun  endfun
   
 " example for no-extension file specific template processing  " example for no-extension file specific template processing
 fun! TemplateFileFunc_noext_makefile ()  fun! TemplateFileFunc_noext_makefile()
         let save_r = @r          let save_r = @r
         let @r = "all:\n\techo your template files need work"          let @r = "all:\n\techo your template files need work"
         normal G          normal G

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top