shell script auto generate the relevant header information (6)

first : add follow context in   /etc/vim/vimrc

set ignorecase
set cursorline
set autoindent
autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
if expand("%:e") == 'sh'
call setline(1,"#!/bin/bash")
call setline(2,"#")
call setline(3,"#********************************************************************")
call setline(4,"#Author: panzidong")
call setline(5,"#Date: ".strftime("%Y-%m-%d"))
call setline(6,"#FileName: ".expand("%"))
call setline(7,"#URL: https://www.cnblogs.com/lianghong881018")
call setline(8,"#Description: The test script")
call setline(9,"#Copyright (C): ".strftime("%Y")." All rights reserved")
call setline(10,"#********************************************************************")
call setline(11,"#")
call setline(12,"")
endif
endfunc
autocmd BufNewFile * normal G

 

second: create new shell scipt 

vim pan.sh

原文地址:https://www.cnblogs.com/lianghong881018/p/10614638.html