自动添加头部注释信息

在用户家目录建立新文件

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

 

 

set ignorecase  #忽略大小写
set cursorline   # 显示光标所在行的横线  
set autoindent  #开启自动给缩进,如果在一行的开头输入空格或制表符,那么后续的新行将会缩进到相同的位置

 

posted @ 2020-03-01 20:00  linux——quan  阅读(361)  评论(0编辑  收藏  举报