New VIM script to automatically add author information (script)
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
New VIM script to automatically add author information (script)