[root@centos8-hkping ~]#vim .vimrc
set ts=4
set expandtab
set shiftwidth=4
set ignorecase
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,"#Author: hkping")i
call setline(4,"#QQ: 275597862")
call setline(5,"#Date: ".strftime("%Y-%m-%d"))
call setline(6,"#FileName: ".expand("%"))
call setline(7,"#Description: The test script")
call setline(8,"#Copyright (C): ".strftime("%Y")." All rights reserved")
call setline(9,"#********************************************************************")
call setline(10,"") endif
endfunc
autocmd BufNewFile * normal G
小技巧:shell脚本自动生成开头注释
于 2022-04-12 13:18:30 首次发布