| version 1.19, 2004/03/29 14:48:53 |
version 1.20, 2004/09/21 20:05:48 |
|
|
| " Vim global plugin for autoload template files |
" Vim global plugin for autoload template files |
| " File: templatefile.vim |
" File: templatefile.vim |
| " Maintainer: Lubomir Host 'rajo' <rajo AT platon.sk> |
" Maintainer: Lubomir Host 'rajo' <rajo AT platon.sk> |
| " Version: $Platon: vimconfig/vim/plugin/templatefile.vim,v 1.18 2003/12/09 07:26:57 rajo Exp $ |
" Version: $Platon: vimconfig/vim/plugin/templatefile.vim,v 1.19 2004/03/29 14:48:53 rajo Exp $ |
| " |
" |
| " Thanks: |
" Thanks: |
| " Scott Urban: First version of templatefile.vim |
" Scott Urban: First version of templatefile.vim |
| Line 32 function! Escape(str) |
|
| Line 32 function! Escape(str) |
|
| return escape(a:str, '/\\') |
return escape(a:str, '/\\') |
| endfunction |
endfunction |
| |
|
| " template file loaded |
" Function LoadTemplateFile() {{{ |
| function! LoadTemplateFile() |
function! LoadTemplateFile() |
| if exists("g:load_templates") |
if exists("g:load_templates") |
| if g:load_templates == "no" |
if g:load_templates == "no" |
| Line 130 function! LoadTemplateFile() |
|
| Line 130 function! LoadTemplateFile() |
|
| " go to first line |
" go to first line |
| silent! execute "normal gg" |
silent! execute "normal gg" |
| endfunction |
endfunction |
| |
" }}} |
| |
|
| function! LoadTemplateFileConfirm(filename) |
" Function <SID>_LoadFile(question, filename) {{{ |
| |
function! <SID>_LoadFile(question, filename) |
| if filereadable(expand(a:filename)) |
if filereadable(expand(a:filename)) |
| if exists("g:load_templates") |
if exists("g:load_templates") |
| if g:load_templates == "ask" |
if g:load_templates == "ask" |
| let choice = confirm("NEW FILE! Load template file " . |
let choice = confirm(a:question . |
| \ expand(a:filename) . " ?:", |
\ expand(a:filename) . " ?:", |
| \ "&yes\n" . |
\ "&yes\n" . |
| \ "&no\n") |
\ "&no\n") |
| if choice == 1 |
if choice == 1 |
| execute "0r " . a:filename |
silent execute "0r " . a:filename |
| setlocal modified |
setlocal modified |
| endif |
endif |
| elseif g:load_templates == "yes" |
elseif g:load_templates == "yes" |
| execute "0r " . a:filename |
silent execute "0r " . a:filename |
| setlocal modified |
setlocal modified |
| endif |
endif |
| else |
else |
| execute "0r " . a:filename |
silent execute "0r " . a:filename |
| setlocal modified |
setlocal modified |
| endif |
endif |
| |
else |
| |
echo "File " . expand(a:filename) . " not found!" |
| endif |
endif |
| endfunction |
endfunction |
| |
" }}} |
| |
|
| |
function! LoadTemplateFileConfirm(filename) |
| |
call <SID>_LoadFile("NEW FILE! Load template file ", a:filename) |
| |
endfunction |
| |
|
| function! LoadFile(filename) |
function! LoadFile(filename) |
| if filereadable(expand(a:filename)) |
call <SID>_LoadFile("Load file ", 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 |
|
| endfunction |
endfunction |
| |
|
| " function from Hojin Choi <pynoos AT naver.com> |
" function from Hojin Choi <pynoos AT naver.com> |
| |
" Function TryLoadTemplateInUpperDir(skelfile) {{{ |
| fun! TryLoadTemplateInUpperDir(skelfile) |
fun! TryLoadTemplateInUpperDir(skelfile) |
| let savewd = getcwd() |
let savewd = getcwd() |
| while (getcwd() != "/") |
while (getcwd() != "/") |
| Line 195 fun! TryLoadTemplateInUpperDir(skelfile) |
|
| Line 187 fun! TryLoadTemplateInUpperDir(skelfile) |
|
| execute "cd " . savewd |
execute "cd " . savewd |
| return 0 |
return 0 |
| endfun |
endfun |
| |
" }}} |
| |
|
| " example for no-extension file specific template processing |
" example for no-extension file specific template processing |
| function! TemplateFileFunc_noext_makefile() |
function! TemplateFileFunc_noext_makefile() |