打开vim的配置文件
vim ~/.vimrc
写入以下内容:
7 autocmd BufNewFile *.sh exec ":call SetTitle()"
8
9 func SetTitle()
10 if expand("%:e")=='sh'
11 call setline(1,"#!/bin/bash")
12 call setline(2,"#")
13 call setline(3,"#*************************************")
14 call setline(4,"#author: nbdj")
15 call setline(5,"#QQ: 41700784")
16 call setline(6,"#email: 41700784@qq.com")
17 call setline(7,"#version: 1.0")
18 call setline(8,"#date: ".strftime("%Y-%m-%d"))
19 call setline(9,"#description: dj test script")
20 call setline(10,"#*************************************")
21
22 endif
23
24 endfunc
新建脚本文件test.sh
vim test.sh
脚本文件的基本信息如下:
1 #!/bin/bash
2 #
3 #*************************************
4 #author: nbdj
5 #QQ: 41700784
6 #email: 41700784@qq.com
7 #version: 1.0
8 #date: 2019-12-23
9 #description: dj test script
10 #*************************************