自动添加shell首部

Posted 拾日迂南

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自动添加shell首部相关的知识,希望对你有一定的参考价值。

vim ~./vimrc

autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
if expand("%:e") == \'sh\'
call setline(1,"#!/bin/bash")
call setline(2,"#********************************************************************")
call setline(3,"#Author     : Oldxu")
call setline(4,"#Date       : ".strftime("%Y-%m-%d"))
call setline(5,"#FileName   : ".expand("%"))
call setline(6,"#Description: The test script")
call setline(7,"#********************************************************************")
call setline(8,"")
endif
endfunc
autocmd BufNewFile * normal G

以上是关于自动添加shell首部的主要内容,如果未能解决你的问题,请参考以下文章