如何在vim创建的脚本内添加固定的头部信息

编辑以下的文件:

vim /etc/vimrc

在脚本的结尾添加如下内容:

autocmd BufNewFile *.sh,*.script exec ":call WESTOS()"
function WESTOS()
call append(0,"#################################")
call append(1,"# Author: Mr.white #")
call append(2,"# Create_Date: ".strftime("%Y-%m-%d")." #")
call append(3,"# Version: 1.0 #")
call append(4,"#################################")

重新建立shell脚本,查看自定义头部信息:

[root@localhost test20210724]# vim test.sh

#################################
# Author: Mr.white #
# Create_Date: 2021-07-03 14:14:21 #
# Version: 1.0 #
#################################

 

posted @ 2021-07-24 20:41  Mrwhite86  阅读(212)  评论(2)    收藏  举报