环境:CentOS 8.5
确定修改全局或者个人变量
全局(修改):etc/vimrc
个人(没有创建): ~/.vimrc
autocmd BufNewFile *.sh exec ":call AutoAddCommentForShell()"
function AutoAddCommentForShell()
call append(0,"#!/bin/bash")
call append(1,"# **********************************************************")
call append(2,"#Author: ZhangSan")
call append(3,"#QQ: 123456789")
call append(4,"#Date: ".strftime("%Y-%m-%d %H:%M"))
call append(5,"#Filename: ".expand("%:t"))
call append(6,"#Description: ")
call append(7,"# **********************************************************")
endfunction
[22:29:48 root@centos8 etc]#vim test.sh
#!/bin/bash
# **********************************************************
#Author: ZhangSan
#QQ: 12345678
#Date: 2021-12-26 22:29
#Filename: test.sh
#Description:
# **********************************************************
~
~
拜了个拜~