在.vimrc中加入如下
set ignorecase set cursorline set autoindent autocmd BufNewFile *.sh exec ":call Bashscript()" autocmd BufNewFile *.py exec ":call Pyscript()" func Bashscript() if expand("%:e") == 'sh' call setline(1,"#!/bin/bash") call setline(2,"##") call setline(3,"#*****************************") call setline(4,"# Author: Brian") call setline(5,"# Mail: hubowestlife@outlook.com") call setline(6,"# Date: ".strftime("%Y-%m-%d")) call setline(7,"# Website: http://hubowestlife.cn") call setline(8,"# Desp: _______script") call setline(9,"#*****************************") call setline(10,"") endif endfunc func Pyscript() if expand("%:e") == 'py' call setline(1,"#!/bin/bash") call setline(2,"##") call setline(3,"#*****************************") call setline(4,"# Author: Brian") call setline(5,"# Mail: hubowestlife@outlook.com") call setline(6,"# Date: ".strftime("%Y-%m-%d")) call setline(7,"# Website: http://hubowestlife.cn") call setline(8,"# Desp: _______script") call setline(9,"#*****************************") call setline(10,"") endif endfunc autocmd BufNewFile * normal G
运行结果如图: