在编写shell脚本的时候经常需要在脚本最开头写一些注释信息,这会浪费掉我们很多的时间,下面给大家分享一个shell脚本的模板文件,当建立一个sh文件时,可以自动生成注释信息,只要把下面的代码拷贝到用户的家目录下并命名成 .vimrc 名称。
- set ignorecase
- set cursorline
- 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: myname")
- call setline(4,"#Date: ".strftime("%y-%m-%d"))
- call setline(5,"#FileName: ".expand("%"))
- call setline(6,"#*************************************************************")
- call setline(7,"")
- endif
- endfunc
- autocmd BufNewFile * normal G