创建模板
vim ~/.vimrc
map <F4> :call AddTitle()<cr>'s
function AddTitle()
call append( 0, "#!/bin/bash")
call append( 1, "#-----------------------------------------------------------------------------------")
call append( 2, "# @Scripts filename: ".expand("%:t"))
call append( 3, "# @Create by: iuskye@126.com")
call append( 4, "# @Date: ".strftime("%Y/%m/%d %H:%M"))
call append( 5, "# @Version: v1.0")
call append( 6, "# @Be used as: usage.")
call append( 7, "# @Usage: sh ".expand("%:t"))
call append( 8, "#-----------------------------------------------------------------------------------")
call append( 9, "")
call append( 10, "")
call append( 11, "#------------------------------- Environment Variable ------------------------------")
call append( 12, "")
call append( 13, "")
call append( 14, "#------------------------------- Function Definetions ------------------------------")
call append( 15, "")
call append( 16, "")
call append( 17, "#---------------------------------- Shell Main Body --------------------------------")
call append( 18, "")
endfunction
使用示例
vim test.sh
# 打开文件后直接按 `F4`
效果