因工作需要经常写shell脚本,每次都要写脚本的头,就想偷个懒,在每次写脚本的时候可以自动生成想要的信息,编辑/etc/vimrc该文件,在新增.sh文件的时候会出现一些信息
autocmd BufNewFile *.sh exec ":call Setcomment()"
func Setcomment()
call append(0,"#!/bin/bash")
call append(1,"#*********************************** ")
call append(2,"#* copyleft test " .strftime("%Y-%m-%d"))
call append(3,"#* scriptname: " .expand("%"))
call append(4,"#* email: sb@localhost")
call append(5,"#* version: v0.1 ")
call append(6,"#*********************************** ")
endfunc
=================================================================================================================================================================================================================================
编辑/etc/vimrc该文件,在新增.sh以及.py文件的时候会出现一些信息
autocmd BufNewFile *.py,*.sh,exec ":call SetTitle()"
let $author_name = "xxx"
let $author_email = "xxx@xxx.xxx"
func SetTitle()
if &filetype == 'sh'
call setline(1,"\###################################################################")
call append(line("."),"\# File Name: ".expand("%"))
call append(line(".")+1,"\# Author: ".$author_name)
call append(line(".")+2,"\# mail: ".$author_email)
call append(line(".")+3,"\# Created Time: ".strftime("%c"))
call append(line(".")+4,"\#=============================================================")
call append(line(".")+5,"\#!/bin/bash")
call append(line(".")+6,"")
else
call setline(1,"\#!/usr/bin/python")
call append(line(".")+6,"")
endif
endfunc
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。