vim /etc/vimrc
####################尾部添加以下代码###############################
map <F4> ms:call AddAuthor()<cr>‘s
function AddAuthor()
let n=1
while n < 5
let line = getline(n)
if line =~‘^\s*\*\s*\S*Last\s*modified\s*:\s*\S*.*$‘
call UpdateTitle()
return
endif
let n = n + 1
endwhile
call AddTitle()
endfunction
function UpdateTitle()
normal m‘
execute ‘/* Last modified\s*:/[email protected]:.*[email protected]\=strftime(": %Y-%m-%d %H:%M")@‘
normal "
normal mk
execute ‘/* Filename\s*:/[email protected]:.*[email protected]\=": ".expand("%:t")@‘
execute "noh"
normal ‘k
echohl WarningMsg | echo "Successful in updating the copy right." | echohl None
endfunction
n AddTitle()
call append(0,"/**********************************************************")
call append(1," * Author : ")
call append(2," * Email : ")
call append(3," * Last modified : ".strftime("%Y-%m-%d %H:%M"))
call append(4," * Filename : ".expand("%:t"))
call append(5," * Description : ")
call append(6," * *******************************************************/")
echohl WarningMsg | echo "Successful in adding the copyright." | echohl None
endfunction