# 编辑家目录~/.vimrc文件,添加以下内容即可
[root@linux-learn ~]# vim ~/.vimrc
[root@linux-learn ~]# cat ~/.vimrc
set nocompatible
filetype plugin indent on
autocmd BufNewFile *.sh exec ":call SeTitle()"
func SeTitle()
if expand("%:e") == 'sh'
call setline(1,"#!/bin/bash")
call setline(2,"#")
call setline(3,"#******************************************************************************************")
call setline(4,"#Author: QianSong")
call setline(5,"#QQ: xxxxxxxx")
call setline(6,"#Date: ".strftime("%Y-%m-%d"))
call setline(7,"#FileName: ".expand("%"))
call setline(8,"#URL: https://github.com/xxxxxx")
call setline(9,"#Description: The test script")
call setline(10,"#Copyright (C): QianSong ".strftime("%Y")." All rights reserved")
call setline(11,"#******************************************************************************************")
call setline(12,"")
endif
endfunc
随便编辑一个shell脚本看看效果
自动添加了注释信息
并且能智能地缩进shell语法
是不是很简单呢,喜欢的话加个收藏、点赞哦~~