编辑vim的配置文件
添加函数
function Octopus() call append(0,"#################################################") call append(1,"# Author: #") call append(2,"# Create_Time:".strftime("%Y-%m-%d")." #") call append(3,"# Version: #") call append(4,"# Description: #") call append(5,"# #") call append(6,"# #") call append(7,"#################################################") call append(8,"") call append(9,"") call append(10,"#!/bin/bash") endfunction
函数调用执行的方法
映射键盘
"map <F9> ms:call Octopus()<cr>'s
自动调用
autocmd BufNewFile *.sh,*.script exec ":call Octopus()"
使用实例

vim 编辑文件test.sh,此时文件头已经添加

文章来源: https://blog.csdn.net/zhangyu_sing/article/details/91126747