系统相关
首页 > 系统相关> > Linux 中shell脚本设置开头固定格式的实现方法

Linux 中shell脚本设置开头固定格式的实现方法

作者:互联网

[root@localhost ~]# vim .vimrc

将下面文件复制进去即可,之后新建一个shell ,开头就会有固定的格式。

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,"#********************************************************************")
call setline(4,"#Author: Lijianhua")
call setline(5,"#QQ: 1957543108")
call setline(6,"#Date: ".strftime("%Y-%m-%d"))
call setline(7,"#FileName: ".expand("%"))
call setline(8,"#URL: http://www.baidu.com")
call setline(9,"#Description: The test script")
call setline(10,"#Copyright (C): ".strftime("%Y")." All rights reserved")
call setline(11,"#********************************************************************")
call setline(12,"")
endif
endfunc
autocmd BufNewFile * normal G
~                                                                                         
~                                  

标签:autocmd,shell,SetTitle,Linux,set,call,setline,格式
来源: https://blog.csdn.net/m0_51974644/article/details/120791015