实现shell脚本模板,自动生成开头注释信息

建议在用户家目录创建.vimrc文件:
文件格式如下:
set ignorecase
set autoindent
set paste
autocmd BufNewFile *.sh exec ":.call SetTitle()"
func SetTitle()
if expand("%:e") == ‘sh‘
call setline(1,"#!/bin/bash")
call setline(2,"#***********************************************")
call setline(3,"#Author:        Tom")
call setline(4,"#Mail:          ")
call setline(5,"#Version:       1.0")
call setline(6,"#Date:          ".strftime("%Y-%m-%d"))
call setline(7,"#FileName:      ".expand("%"))
call setline(8,"#Description:   The test script")
call setline(9,"#***********************************************")
call setline(10,"")
endif
endfunc
autocmd BufNewFile * normal G

相关推荐