11 autocmd BufNewFile *.sh exec ":call MyTitle()" 12 func MyTitle() 13 if expand("%:e") == 'sh' 14 call setline(1,"#!/bin/bash") 15 call setline(2,"#=================================================================") 16 call setline(3,":<<readme") 17 call setline(4,"Author: liuye") 18 call setline(5,"QQ: 931478729 ") 19 call setline(6,"Date: ".strftime("%Y-%m-%d")) 20 call setline(7,"FileName: ".expand("%")) 21 call setline(8,"URL: https://home.cnblogs.com/u/axjlxy/") 22 call setline(9,"Destcription study shell script") 23 call setline(10,"Copyright (C) ".strftime("%Y")." All right reserved") 24 call setline(11,"readme") 25 call setline(12,"#=================================================================") 26 call setline(13,"") 27 endif 28 endfunc 29 autocmd BufNewFile * normal G
在家目錄的vimrc中添加如上代碼段source ~/.vimrc便可shell