New VIM script to automatically add author information (script)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.