- 编辑文件:
~/.vimrc
,增加以下内容(也可以按照格式自行增加和减少内容即可)
autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
if expand("%:e") == 'sh'
call setline(1,"#!/usr/bin/env bash")
call setline(2,"#********************************************************************")
call setline(3,"#Author : whale")
call setline(4,"#Date : ".strftime("%Y-%m-%d"))
call setline(5,"#Name : ".expand("%"))
call setline(6,"#Description: xxxxxxx")
call setline(7,"#********************************************************************")
endif
endfunc
autocmd BufNewFile * normal G
- 通过
vim xxxx.sh
编辑的脚本文件就会自动生成上面的头部了