马哥Shell学习笔记之--给Shell脚本自动添加注释

本脚本资料收集于马哥教育,版权归马哥教育所有

在某用户家目录下创建.vimrc文件,文件内容如下:

set ignorecase
set cursorline
set autoindent
autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
if expand("%:e") == 'sh'
call setline(1,"#!/bin/sh")
call setline(2,"#")
call setline(3,"#****")
call setline(4,"#Author: tomshen")
call setline(5,"#QQ: ×××")
call setline(6,"#Date:" .strftime("%Y-%m-%d"))
call setline(7,"#FileName: ".expand("%"))
call setline(8,"#Description: The test script")
call setline(9,"#Copyright (C): ".strftime("%Y")." All rights reserved")
call setline(10,"#***")
call setline(11,"")
endif

endfunc
autocmd BufNewFile * normal G