1
jiang42 2014-12-14 21:46:06 +08:00
同求,现在是用UltiSnips 添加,也还行
|
2
jamesxu 2014-12-14 21:58:33 +08:00
1、http://www.vim.org/scripts/script.php?script_id=4786
2、参考:au BufNewFile *.py 0r ~/.vim/skeletons/skel.python |
3
weegc 2014-12-15 10:06:21 +08:00
试试snipmate
|
4
josephpei 2014-12-15 10:15:14 +08:00 1
function ReadTempl(fname)
let l:fpath=expand(a:fname) let l:lines=readfile(l:fpath, "", 10000) if !append(0, l:lines) let l:date = strftime("%c") let l:year = strftime("%Y") let l:author = "Your Name<[email protected]>" let l:filename = expand("%") let l:incguard = toupper("_" . substitute(l:filename, "\\.", "_", "g")) silent! exec "%s#\$DATE#". l:date . "#g" silent! exec "%s#\$YEAR#". l:year . "#g" silent! exec "%s#\$AUTHOR#". l:author . "#g" silent! exec "%s#\$FILE_NAME#". l:filename . "#g" silent! exec "%s#\$INC_GUARD#". l:incguard . "#g" silent! exec "normal G" endif endf if has("autocmd") autocmd BufEnter * :cd %:p:h autocmd BufNewFile *.py call ReadTempl("~/.vim/templ/python.tpl") autocmd BufNewFile *.h call ReadTempl("~/.vim/templ/cpp_h.tpl") autocmd BufNewFile *.c,*.cpp call ReadTempl("~/.vim/templ/cpp_m.tpl") autocmd Bufwritepre,filewritepre *.c,*.cpp,*.h,*.py execute "normal mz" autocmd Bufwritepre,filewritepre *.c,*.cpp,*.h,*.py exe "1," . 15 . "g/Last Modified :.*/s/Last Modified :.*/Last Modified : " .strftime("%c") autocmd bufwritepost,filewritepost *.c,*.cpp,*.h,*.py execute "normal `z" "autocmd! BufNewFile * silent! 0r ~/.vim/skel/Template.%:e "autocmd BufNewFile *.html 0r ~/.vim/template/html.tpl endif " has("autocmd") ------------- python.tpl #!/usr/bin/python # -*- coding: utf-8 -*- # $FILE_NAME - description # Copyright (C) $YEAR $AUTHOR # Date : $DATE # Last Modified : |